1
|
PHPMailer
|
2
|
Full Featured Email Transfer Class for PHP
|
3
|
==========================================
|
4
|
|
5
|
http://phpmailer.sourceforge.net/
|
6
|
|
7
|
This software is licenced under the LGPL. Please read LICENSE for information on the
|
8
|
software availability and distribution.
|
9
|
|
10
|
Class Features:
|
11
|
- Send emails with multiple TOs, CCs, BCCs and REPLY-TOs
|
12
|
- Redundant SMTP servers
|
13
|
- Multipart/alternative emails for mail clients that do not read HTML email
|
14
|
- Support for 8bit, base64, binary, and quoted-printable encoding
|
15
|
- Uses the same methods as the very popular AspEmail active server (COM) component
|
16
|
- SMTP authentication
|
17
|
- Native language support
|
18
|
- Word wrap, and more!
|
19
|
|
20
|
Why you might need it:
|
21
|
|
22
|
Many PHP developers utilize email in their code. The only PHP function
|
23
|
that supports this is the mail() function. However, it does not expose
|
24
|
any of the popular features that many email clients use nowadays like
|
25
|
HTML-based emails and attachments. There are two proprietary
|
26
|
development tools out there that have all the functionality built into
|
27
|
easy to use classes: AspEmail(tm) and AspMail. Both of these
|
28
|
programs are COM components only available on Windows. They are also a
|
29
|
little pricey for smaller projects.
|
30
|
|
31
|
Since I do Linux development I?ve missed these tools for my PHP coding.
|
32
|
So I built a version myself that implements the same methods (object
|
33
|
calls) that the Windows-based components do. It is open source and the
|
34
|
LGPL license allows you to place the class in your proprietary PHP
|
35
|
projects.
|
36
|
|
37
|
|
38
|
Installation:
|
39
|
|
40
|
Copy class.phpmailer.php into your php.ini include_path. If you are
|
41
|
using the SMTP mailer then place class.smtp.php in your path as well.
|
42
|
In the language directory you will find several files like
|
43
|
phpmailer.lang-en.php. If you look right before the .php extension
|
44
|
that there are two letters. These represent the language type of the
|
45
|
translation file. For instance "en" is the English file and "br" is
|
46
|
the Portuguese file. Chose the file that best fits with your language
|
47
|
and place it in the PHP include path. If your language is English
|
48
|
then you have nothing more to do. If it is a different language then
|
49
|
you must point PHPMailer to the correct translation. To do this, call
|
50
|
the PHPMailer SetLanguage method like so:
|
51
|
|
52
|
// To load the Portuguese version
|
53
|
$mail->SetLanguage("br", "/optional/path/to/language/directory/");
|
54
|
|
55
|
That's it. You should now be ready to use PHPMailer!
|
56
|
|
57
|
|
58
|
A Simple Example:
|
59
|
|
60
|
<?php
|
61
|
require("class.phpmailer.php");
|
62
|
|
63
|
$mail = new PHPMailer();
|
64
|
|
65
|
$mail->IsSMTP(); // set mailer to use SMTP
|
66
|
$mail->Host = "smtp1.example.com;smtp2.example.com"; // specify main and backup server
|
67
|
$mail->SMTPAuth = true; // turn on SMTP authentication
|
68
|
$mail->Username = "jswan"; // SMTP username
|
69
|
$mail->Password = "secret"; // SMTP password
|
70
|
|
71
|
$mail->From = "from@example.com";
|
72
|
$mail->FromName = "Mailer";
|
73
|
$mail->AddAddress("josh@example.net", "Josh Adams");
|
74
|
$mail->AddAddress("ellen@example.com"); // name is optional
|
75
|
$mail->AddReplyTo("info@example.com", "Information");
|
76
|
|
77
|
$mail->WordWrap = 50; // set word wrap to 50 characters
|
78
|
$mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments
|
79
|
$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name
|
80
|
$mail->IsHTML(true); // set email format to HTML
|
81
|
|
82
|
$mail->Subject = "Here is the subject";
|
83
|
$mail->Body = "This is the HTML message body <b>in bold!</b>";
|
84
|
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
|
85
|
|
86
|
if(!$mail->Send())
|
87
|
{
|
88
|
echo "Message could not be sent. <p>";
|
89
|
echo "Mailer Error: " . $mail->ErrorInfo;
|
90
|
exit;
|
91
|
}
|
92
|
|
93
|
echo "Message has been sent";
|
94
|
?>
|
95
|
|
96
|
CHANGELOG
|
97
|
|
98
|
See ChangeLog.txt
|
99
|
|
100
|
Download: http://sourceforge.net/project/showfiles.php?group_id=26031
|
101
|
|
102
|
Brent R. Matzelle
|