Skip to content

Commit

Permalink
Import 5.2.2rc2 from Google Code
Browse files Browse the repository at this point in the history
Major cleanup of PHPDocs
Test suite works again
  • Loading branch information
Synchro committed Nov 21, 2012
1 parent be7f588 commit 6f919df
Show file tree
Hide file tree
Showing 57 changed files with 2,799 additions and 1,374 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
docs/phpdoc/
test/message.txt
test/testbootstrap.php
249 changes: 64 additions & 185 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# PHPMailer - Full Featured Email Transfer Class for PHP
# PHPMailer - A full-featured email creation and transfer class for PHP

## License

This software is licenced under the LGPL. Please read LICENSE for information on the
This software is licenced under the [LGPL](http://www.gnu.org/licenses/lgpl-2.1.html). Please read LICENSE for information on the
software availability and distribution.

## Class Features:
Expand All @@ -14,216 +14,95 @@ software availability and distribution.
- Uses the same methods as the very popular AspEmail active server (COM) component
- SMTP authentication
- Native language support
- Word wrap, and more!
- Word wrap
- Compatible with PHP 5.0 and later
- Much more!

## Why you might need it:

Many PHP developers utilize email in their code. The only PHP function
that supports this is the mail() function. However, it does not expose
any of the popular features that many email clients use nowadays like
HTML-based emails and attachments. There are two proprietary
development tools out there that have all the functionality built into
easy to use classes: AspEmail(tm) and AspMail. Both of these
programs are COM components only available on Windows. They are also a
little pricey for smaller projects.

Since I do Linux development I've missed these tools for my PHP coding.
So I built a version myself that implements the same methods (object
calls) that the Windows-based components do. It is open source and the
LGPL license allows you to place the class in your proprietary PHP
projects.
Many PHP developers utilize email in their code. The only PHP function that supports this is the mail() function. However, it does not provide any assistance for making use of popular features such as HTML-based emails and attachments.

Formatting email correctly is surprisingly difficult. There are myriad overlapping RFCs, requiring tight adherence to horribly complicated formatting and encoding rules - the vast majority of code that you'll find online that uses the mail() function directly is just plain wrong!
*Please* don't be tempted to do it yourself - if you don't use PHPMailer, there are many other excellent libraries that you should look at before rolling your own - try SwiftMailer, Zend_Mail, eZcomponents etc.

The PHP mail() function usually sends via a local mail server, typically fronted by a `sendmail` binary on Linux, BSD and OS X platforms, however, Windows usually doesn't include a local mail server; PHPMailer's integrated SMTP implementation allows email sending on Windows platforms without a local mail server.

## Installation:

Copy class.phpmailer.php into your php.ini include_path. If you are
using the SMTP mailer then place class.smtp.php in your path as well.
In the language directory you will find several files like
phpmailer.lang-en.php. If you look right before the .php extension
that there are two letters. These represent the language type of the
translation file. For instance "en" is the English file and "br" is
the Portuguese file. Choose the file that best fits with your language
and place it in the PHP include path. If your language is English
then you have nothing more to do. If it is a different language then
you must point PHPMailer to the correct translation. To do this, call
the PHPMailer SetLanguage method like so:
Copy the contents of the PHPMailer folder into somewhere that's in your PHP include_path setting.

## Localization
PHPMailer defaults to English, but in the `languages` folder you'll find numerous translations for PHPMailer error messages that you may encounter. Their filenames contain [ISO 639-1](http://en.wikipedia.org/wiki/ISO_639-1) language code for the translations, for example `fr` for French. To specify a language, you need to tell PHPMailer which one to use, like this:

```php
// To load the Portuguese version
$mail->SetLanguage("br", "/optional/path/to/language/directory/");
// To load the French version
$mail->SetLanguage('fr', '/optional/path/to/language/directory/');
```

That's it. You should now be ready to use PHPMailer!

## A Simple Example:
## A Simple Example

```php
<?php
require("class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "smtp1.example.com;smtp2.example.com"; // specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "jswan"; // SMTP username
$mail->Password = "secret"; // SMTP password

$mail->From = "[email protected]";
$mail->FromName = "Mailer";
$mail->AddAddress("[email protected]", "Josh Adams");
$mail->AddAddress("[email protected]"); // name is optional
$mail->AddReplyTo("[email protected]", "Information");

$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments
$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name
$mail->IsHTML(true); // set email format to HTML

$mail->Subject = "Here is the subject";
$mail->Body = "This is the HTML message body <b>in bold!</b>";
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";

if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
require 'class.phpmailer.php';

$mail = new PHPMailer;

$mail->IsSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup server
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'jswan'; // SMTP username
$mail->Password = 'secret'; // SMTP password

$mail->From = '[email protected]';
$mail->FromName = 'Mailer';
$mail->AddAddress('[email protected]', 'Josh Adams'); // Add a recipient
$mail->AddAddress('[email protected]'); // Name is optional
$mail->AddReplyTo('[email protected]', 'Information');

$mail->WordWrap = 50; // Set word wrap to 50 characters
$mail->AddAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->AddAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->IsHTML(true); // Set email format to HTML

$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

if(!$mail->Send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}

echo "Message has been sent";
?>
echo 'Message has been sent';
```

## CHANGELOG

See ChangeLog.txt

Download: http://sourceforge.net/project/showfiles.php?group_id=26031

Andy Prevost

## History (see changelog.txt for more)

Version 5.2.1 (January 16, 2012)

Patch release (see changelog.txt).

Version 5.2.0 (July 19, 2011)

With the release of this version, PHPMailer has moved to Apache
Extras:
http://code.google.com/a/apache-extras.org/p/phpmailer/

Version 5.0.0 (April 02, 2009)

With the release of this version, we are initiating a new version numbering
system to differentiate from the PHP4 version of PHPMailer.

Most notable in this release is fully object oriented code.

We now have available the PHPDocumentor (phpdocs) documentation. This is
separate from the regular download to keep file sizes down. Please see the
download area of http://phpmailer.codeworxtech.com.

We also have created a new test script (see /test_script) that you can use
right out of the box. Copy the /test_script folder directly to your server (in
the same structure ... with class.phpmailer.php and class.smtp.php in the
folder above it. Then launch the test script with:
http://www.yourdomain.com/phpmailer/test_script/index.php
from this one script, you can test your server settings for mail(), sendmail (or
qmail), and SMTP. This will email you a sample email (using contents.html for
the email body) and two attachments. One of the attachments is used as an inline
image to demonstrate how PHPMailer will automatically detect if attachments are
the same source as inline graphics and only include one version. Once you click
the Submit button, the results will be displayed including any SMTP debug
information and send status. We will also display a version of the script that
you can cut and paste to include in your projects. Enjoy!

Version 2.3 (November 08, 2008)

We have removed the /phpdoc from the downloads. All documentation is now on
the http://phpmailer.codeworxtech.com website.

The phpunit.php has been updated to support PHP5.

For all other changes and notes, please see the changelog.

Donations are accepted at PayPal with our id "[email protected]".

Version 2.2 (July 15 2008)

- see the changelog.

Version 2.1 (June 04 2008)

With this release, we are announcing that the development of PHPMailer for PHP5
will be our focus from this date on. We have implemented all the enhancements
and fixes from the latest release of PHPMailer for PHP4.

Far more important, though, is that this release of PHPMailer (v2.1) is
fully tested with E_STRICT error checking enabled.

** NOTE: WE HAVE A NEW LANGUAGE VARIABLE FOR DIGITALLY SIGNED S/MIME EMAILS.
IF YOU CAN HELP WITH LANGUAGES OTHER THAN ENGLISH AND SPANISH, IT WOULD BE
APPRECIATED.

We have now added S/MIME functionality (ability to digitally sign emails).
BIG THANKS TO "sergiocambra" for posting this patch back in November 2007.
The "Signed Emails" functionality adds the Sign method to pass the private key
filename and the password to read it, and then email will be sent with
content-type multipart/signed and with the digital signature attached.

A quick note on E_STRICT:

- In about half the test environments the development version was subjected
to, an error was thrown for the date() functions (used at line 1565 and 1569).
This is NOT a PHPMailer error, it is the result of an incorrectly configured
PHP5 installation. The fix is to modify your 'php.ini' file and include the
date.timezone = America/New York
directive, (for your own server timezone)
- If you do get this error, and are unable to access your php.ini file, there is
a workaround. In your PHP script, add
date_default_timezone_set('America/Toronto');

* do NOT try to use
$myVar = date_default_timezone_get();
as a test, it will throw an error.

We have also included more example files to show the use of "sendmail", "mail()",
"smtp", and "gmail".
You'll find plenty more to play with in the `examples` folder.

We are also looking for more programmers to join the volunteer development team.
If you have an interest in this, please let us know.
That's it. You should now be ready to use PHPMailer!

Enjoy!
## Documentation

You'll find some basic user-level docs in the docs folder, and you can generate complete API-level documentation using the `generatedocs.sh` shell script in the docs folder, though you'll need to install [PHPDocumentor](http://www.phpdoc.org) first.

Version 2.1.0beta1 & beta2
## Tests

please note, this is BETA software
** DO NOT USE THIS IN PRODUCTION OR LIVE PROJECTS
INTENDED STRICTLY FOR TESTING
You'll find a PHPUnit test script in the `test` folder.

** NOTE:
## Contributing

As of November 2007, PHPMailer has a new project team headed by industry
veteran Andy Prevost (codeworxtech). The first release in more than two
years will focus on fixes, adding ease-of-use enhancements, provide
basic compatibility with PHP4 and PHP5 using PHP5 backwards compatibility
features. A new release is planned before year-end 2007 that will provide
full compatiblity with PHP4 and PHP5, as well as more bug fixes.
Please submit bug reports, suggestions and pull requests to the [Google Code tracker](https://code.google.com/a/apache-extras.org/p/phpmailer/issues/list) or the [GitHub issue tracker](https://github.com/Synchro/PHPMailer/issues).

We are looking for project developers to assist in restoring PHPMailer to
its leadership position. Our goals are to simplify use of PHPMailer, provide
good documentation and examples, and retain backward compatibility to level
1.7.3 standards.
We're particularly interested in fixes for edge-cases, expanding test coverage and updating translations.

If you are interested in helping out, visit http://sourceforge.net/projects/phpmailer
and indicate your interest.
Please *don't* use the sourceforge project any more.

**
## Changelog

## See also
See changelog.txt

http://phpmailer.sourceforge.net/
http://code.google.com/a/apache-extras.org/p/phpmailer/
## History
PHPMailer was originally written in 2001 by Brent R. Matzelle as a [sourceforge project](http://sourceforge.net/projects/phpmailer/).
Marcus Bointon (coolbru on SF) and Andy Prevost (codeworxtech) took over the project in 2004.
The project became an [Apache incubator project on Google Code](https://code.google.com/a/apache-extras.org/p/phpmailer/) in 2010, managed by Jim Jagielski
Marcus maintains a [GitHub repository](https://github.com/Synchro/PHPMailer) that's kept in sync with the Google Code project as far as is practical.
Loading

0 comments on commit 6f919df

Please sign in to comment.