Merge branch 'master' into 5.4
Bump version to 5.5 Clean up code generator # Conflicts: # README.md # examples/send_file_upload.phps # src/SMTP.php # test/phpmailerTest.php
This commit is contained in:
parent
27501ac7b9
commit
33f82ab517
|
|
@ -3,7 +3,6 @@ php:
|
|||
- 7.0
|
||||
- 5.6
|
||||
- 5.5
|
||||
- 5.4
|
||||
- hhvm
|
||||
matrix:
|
||||
allow_failures:
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ software availability and distribution.
|
|||
PHPMailer is available on [Packagist](https://packagist.org/packages/phpmailer/phpmailer) (using semantic versioning), and installation via composer is the recommended way to install PHPMailer. Just add this line to your `composer.json` file:
|
||||
|
||||
```json
|
||||
"phpmailer/phpmailer": "~5.4"
|
||||
"phpmailer/phpmailer": "~5.5"
|
||||
```
|
||||
|
||||
or run
|
||||
|
|
@ -132,7 +132,7 @@ If the documentation doesn't cover what you need, search the [many questions on
|
|||
|
||||
## Tests
|
||||
|
||||
There is a PHPUnit test script in the [test](https://github.com/PHPMailer/PHPMailer/tree/master/test/) folder. PHPMailer uses PHPUnit 4.8 - we would use 5.0 but we need to run on PHP 5.4.
|
||||
There is a PHPUnit test script in the [test](https://github.com/PHPMailer/PHPMailer/tree/master/test/) folder. PHPMailer uses PHPUnit 4.8 - we would use 5.x but we need to run on PHP 5.5.
|
||||
|
||||
Build status: [](https://travis-ci.org/PHPMailer/PHPMailer)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
# ChangeLog
|
||||
|
||||
## Version 5.4
|
||||
This is a major update that breaks backwards compatibility. To emphasise that this release requires PHP 5.4, this release is called **5.4**, **not 5.3**!
|
||||
## Version 5.5
|
||||
This is a major update that breaks backwards compatibility. To emphasise that this release requires PHP 5.5, this release is called **5.5**, **not 5.3**!
|
||||
|
||||
* Requires PHP 5.4 or later
|
||||
* Requires PHP 5.5 or later
|
||||
* Uses the `PHPMailer\PHPMailer` namespace
|
||||
* File structure simplified, classes live in the `src/` folder
|
||||
* Custom autoloader has been removed, now PSR-4 compatible
|
||||
* Custom autoloader has been removed, now PSR-4 compatible: **use composer**!
|
||||
* Classes renamed to make use of the namespace
|
||||
* `Extras` classes have been removed - use packages from packagist.org instead
|
||||
* All elements previously marked as deprecated have been removed:
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.4.0"
|
||||
"php": ">=5.5.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpdocumentor/phpdocumentor": "2.*",
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
* revised, updated and corrected 27/02/2013
|
||||
* by matt.sturdy@gmail.com
|
||||
*/
|
||||
|
||||
namespace PHPMailer\PHPMailer;
|
||||
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
$CFG['smtp_debug'] = 2; //0 == off, 1 for client output, 2 for client and server
|
||||
|
|
@ -40,7 +43,8 @@ $results_messages = [];
|
|||
|
||||
// $example_code represents the "final code" that we're using, and will
|
||||
// be shown to the user at the end.
|
||||
$example_code = "\nrequire_once '../PHPMailerAutoload.php';";
|
||||
$example_code = "<?php\nnamespace PHPMailer\\PHPMailer;";
|
||||
$example_code .= "\nrequire_once 'vendor/autoload.php';";
|
||||
$example_code .= "\n\n\$results_messages = [];";
|
||||
|
||||
$mail = new PHPMailer(true); //PHPMailer instance with exceptions enabled
|
||||
|
|
@ -51,23 +55,23 @@ $example_code .= "\n\n\$mail = new PHPMailer(true);";
|
|||
$example_code .= "\n\$mail->CharSet = 'utf-8';";
|
||||
$example_code .= "\nini_set('default_charset', 'UTF-8');";
|
||||
|
||||
class phpmailerAppException extends phpmailerException
|
||||
class AppException extends Exception
|
||||
{
|
||||
}
|
||||
|
||||
$example_code .= "\n\nclass phpmailerAppException extends phpmailerException {}";
|
||||
$example_code .= "\n\nclass AppException extends Exception {}";
|
||||
$example_code .= "\n\ntry {";
|
||||
|
||||
try {
|
||||
if (isset($_POST["submit"]) && $_POST['submit'] == "Submit") {
|
||||
$to = $_POST['To_Email'];
|
||||
if (!PHPMailer::validateAddress($to)) {
|
||||
throw new phpmailerAppException("Email address " . $to . " is invalid -- aborting!");
|
||||
throw new AppException("Email address " . $to . " is invalid -- aborting!");
|
||||
}
|
||||
|
||||
$example_code .= "\n\$to = '{$_POST['To_Email']}';";
|
||||
$example_code .= "\nif(!PHPMailer::validateAddress(\$to)) {";
|
||||
$example_code .= "\n throw new phpmailerAppException(\"Email address \" . " .
|
||||
$example_code .= "\n throw new AppException(\"Email address \" . " .
|
||||
"\$to . \" is invalid -- aborting!\");";
|
||||
$example_code .= "\n}";
|
||||
|
||||
|
|
@ -113,7 +117,7 @@ try {
|
|||
$example_code .= "\n\$mail->isQmail();";
|
||||
break;
|
||||
default:
|
||||
throw new phpmailerAppException('Invalid test_type provided');
|
||||
throw new AppException('Invalid test_type provided');
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
@ -157,8 +161,8 @@ try {
|
|||
$example_code .= "\n\$mail->addCC(\"$value\");";
|
||||
}
|
||||
}
|
||||
} catch (phpmailerException $e) { //Catch all kinds of bad addressing
|
||||
throw new phpmailerAppException($e->getMessage());
|
||||
} catch (Exception $e) { //Catch all kinds of bad addressing
|
||||
throw new AppException($e->getMessage());
|
||||
}
|
||||
$mail->Subject = $_POST['Subject'] . ' (PHPMailer test using ' . strtoupper($_POST['test_type']) . ')';
|
||||
$example_code .= "\n\$mail->Subject = \"" . $_POST['Subject'] .
|
||||
|
|
@ -190,21 +194,21 @@ try {
|
|||
strtoupper($_POST['test_type']) . "\";";
|
||||
$example_code .= "\n}";
|
||||
$example_code .= "\ncatch (phpmailerException \$e) {";
|
||||
$example_code .= "\n throw new phpmailerAppException('Unable to send to: ' . \$to. ': '.\$e->getMessage());";
|
||||
$example_code .= "\n throw new AppException('Unable to send to: ' . \$to. ': '.\$e->getMessage());";
|
||||
$example_code .= "\n}";
|
||||
|
||||
try {
|
||||
$mail->send();
|
||||
$results_messages[] = "Message has been sent using " . strtoupper($_POST["test_type"]);
|
||||
} catch (phpmailerException $e) {
|
||||
throw new phpmailerAppException("Unable to send to: " . $to . ': ' . $e->getMessage());
|
||||
} catch (Exception $e) {
|
||||
throw new AppException("Unable to send to: " . $to . ': ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
} catch (phpmailerAppException $e) {
|
||||
} catch (AppException $e) {
|
||||
$results_messages[] = $e->errorMessage();
|
||||
}
|
||||
$example_code .= "\n}";
|
||||
$example_code .= "\ncatch (phpmailerAppException \$e) {";
|
||||
$example_code .= "\ncatch (AppException \$e) {";
|
||||
$example_code .= "\n \$results_messages[] = \$e->errorMessage();";
|
||||
$example_code .= "\n}";
|
||||
$example_code .= "\n\nif (count(\$results_messages) > 0) {";
|
||||
|
|
@ -356,9 +360,9 @@ $example_code .= "\n}";
|
|||
</head>
|
||||
<body>
|
||||
<?php
|
||||
if (version_compare(PHP_VERSION, '5.4.0', '<')) {
|
||||
if (version_compare(PHP_VERSION, '5.5.0', '<')) {
|
||||
echo 'Current PHP version: ' . phpversion() . "<br>";
|
||||
echo exit("ERROR: Wrong PHP version. Must be PHP 5.4 or later.");
|
||||
echo exit("ERROR: Wrong PHP version. Must be PHP 5.5 or later.");
|
||||
}
|
||||
|
||||
if (count($results_messages) > 0) {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ $mysql = mysqli_connect('localhost', 'username', 'password');
|
|||
mysqli_select_db($mysql, 'mydb');
|
||||
$result = mysqli_query($mysql, 'SELECT full_name, email, photo FROM mailinglist WHERE sent = false');
|
||||
|
||||
foreach ($result as $row) { //This iterator syntax only works in PHP 5.4+
|
||||
foreach ($result as $row) {
|
||||
$mail->addAddress($row['email'], $row['full_name']);
|
||||
if (!empty($row['photo'])) {
|
||||
$mail->addStringAttachment($row['photo'], 'YourPhoto.jpg'); //Assumes the image data is stored in the DB
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
* * Set the script address as the app's redirect URL
|
||||
* If no refresh token is obtained when running this file, revoke access to your app
|
||||
* using link: https://accounts.google.com/b/0/IssuedAuthSubTokens and run the script again.
|
||||
* This script requires PHP 5.4 or later
|
||||
* PHP Version 5.4
|
||||
* This script requires PHP 5.5 or later
|
||||
* PHP Version 5.5
|
||||
*/
|
||||
|
||||
namespace League\OAuth2\Client\Provider;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer - PHP email creation and transport class.
|
||||
* PHP Version 5.4
|
||||
* PHP Version 5.5
|
||||
* @package PHPMailer
|
||||
* @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
|
||||
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer - PHP email creation and transport class.
|
||||
* PHP Version 5.4
|
||||
* PHP Version 5.5
|
||||
* @package PHPMailer
|
||||
* @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
|
||||
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
|
||||
|
|
@ -586,7 +586,7 @@ class PHPMailer
|
|||
/**
|
||||
* The PHPMailer Version number.
|
||||
*/
|
||||
const VERSION = '5.4.0';
|
||||
const VERSION = '5.5.0';
|
||||
|
||||
/**
|
||||
* Error severity: message only, continue processing.
|
||||
|
|
@ -1608,7 +1608,7 @@ class PHPMailer
|
|||
*/
|
||||
public function smtpClose()
|
||||
{
|
||||
if (is_a($this->smtp, 'SMTP')) {
|
||||
if (!is_null($this->smtp)) {
|
||||
if ($this->smtp->connected()) {
|
||||
$this->smtp->quit();
|
||||
$this->smtp->close();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer - PHP email creation and transport class.
|
||||
* PHP Version 5.4
|
||||
* PHP Version 5.5
|
||||
* @package PHPMailer
|
||||
* @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
|
||||
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class POP3
|
|||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $Version = '5.4.0';
|
||||
public $Version = '5.5.0';
|
||||
|
||||
/**
|
||||
* Default POP3 port number.
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class SMTP
|
|||
* The PHPMailer SMTP version number.
|
||||
* @var string
|
||||
*/
|
||||
const VERSION = '5.4.0';
|
||||
const VERSION = '5.5.0';
|
||||
|
||||
/**
|
||||
* SMTP line break constant.
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@
|
|||
/**
|
||||
* PHPMailer - language file tests
|
||||
*
|
||||
* PHP version 5.4.0
|
||||
*
|
||||
* PHP version 5.5.0
|
||||
* @package PHPMailer
|
||||
* @author Marcus Bointon <phpmailer@synchromedia.co.uk>
|
||||
* @author Andy Prevost
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/**
|
||||
* PHPMailer - PHP email transport unit tests.
|
||||
*
|
||||
* PHP version 5.4.0
|
||||
* PHP version 5.5.0
|
||||
* @package PHPMailer
|
||||
* @author Marcus Bointon <phpmailer@synchromedia.co.uk>
|
||||
* @author Andy Prevost
|
||||
|
|
@ -50,7 +50,7 @@ class PHPMailerTest extends \PHPUnit_Framework_TestCase
|
|||
* Default include path
|
||||
* @var string
|
||||
*/
|
||||
public $INCLUDE_DIR = './';
|
||||
public $INCLUDE_DIR = '..';
|
||||
|
||||
/**
|
||||
* PIDs of any processes we need to kill
|
||||
|
|
@ -724,7 +724,7 @@ class PHPMailerTest extends \PHPUnit_Framework_TestCase
|
|||
$this->Mail->Body = 'Here is the text body';
|
||||
$this->Mail->Subject .= ': Plain + Multiple FileAttachments';
|
||||
|
||||
if (!$this->Mail->addAttachment(realpath($this->INCLUDE_DIR . 'examples/images/phpmailer.png'))) {
|
||||
if (!$this->Mail->addAttachment(realpath($this->INCLUDE_DIR . '/examples/images/phpmailer.png'))) {
|
||||
$this->assertTrue(false, $this->Mail->ErrorInfo);
|
||||
return;
|
||||
}
|
||||
|
|
@ -825,7 +825,7 @@ EOT;
|
|||
|
||||
//This file is in ISO-8859-1 charset
|
||||
//Needs to be external because this file is in UTF-8
|
||||
$content = file_get_contents(realpath($this->INCLUDE_DIR.'/examples/contents.html'));
|
||||
$content = file_get_contents(realpath($this->INCLUDE_DIR . '/examples/contents.html'));
|
||||
// This is the string 'éèîüçÅñæß' in ISO-8859-1, base-64 encoded
|
||||
$check = base64_decode('6eju/OfF8ebf');
|
||||
//Make sure it really is in ISO-8859-1!
|
||||
|
|
@ -835,7 +835,7 @@ EOT;
|
|||
"ISO-8859-1",
|
||||
mb_detect_encoding($content, "UTF-8, ISO-8859-1, ISO-8859-15", true)
|
||||
),
|
||||
realpath($this->INCLUDE_DIR . 'examples')
|
||||
realpath($this->INCLUDE_DIR . '/examples')
|
||||
);
|
||||
$this->buildBody();
|
||||
$this->assertTrue(
|
||||
|
|
@ -899,7 +899,7 @@ EOT;
|
|||
</html>
|
||||
EOT;
|
||||
$this->Mail->addEmbeddedImage(
|
||||
realpath($this->INCLUDE_DIR . 'examples/images/phpmailer.png'),
|
||||
realpath($this->INCLUDE_DIR . '/examples/images/phpmailer.png'),
|
||||
'my-attach',
|
||||
'phpmailer.png',
|
||||
'base64',
|
||||
|
|
@ -935,13 +935,14 @@ EOT;
|
|||
*/
|
||||
public function testMsgHTML()
|
||||
{
|
||||
$message = file_get_contents(realpath($this->INCLUDE_DIR . 'examples/contentsutf8.html'));
|
||||
$message = file_get_contents(realpath($this->INCLUDE_DIR . '/examples/contentsutf8.html'));
|
||||
$this->Mail->CharSet = 'utf-8';
|
||||
$this->Mail->Body = '';
|
||||
$this->Mail->AltBody = '';
|
||||
//Uses internal HTML to text conversion
|
||||
$this->Mail->msgHTML($message, realpath($this->INCLUDE_DIR . 'examples'));
|
||||
$this->Mail->msgHTML($message, realpath($this->INCLUDE_DIR . '/examples'));
|
||||
$this->Mail->Subject .= ': msgHTML';
|
||||
$this->Mail->addAddress('user@example.com');
|
||||
|
||||
$this->assertNotEmpty($this->Mail->Body, 'Body not set by msgHTML');
|
||||
$this->assertNotEmpty($this->Mail->AltBody, 'AltBody not set by msgHTML');
|
||||
|
|
@ -972,7 +973,9 @@ EOT;
|
|||
$this->Mail->isHTML(true);
|
||||
|
||||
if (!$this->Mail->addAttachment(
|
||||
realpath($this->INCLUDE_DIR . 'examples/images/phpmailer_mini.png'), 'phpmailer_mini.png')
|
||||
realpath($this->INCLUDE_DIR . '/examples/images/phpmailer_mini.png'),
|
||||
'phpmailer_mini.png'
|
||||
)
|
||||
) {
|
||||
$this->assertTrue(false, $this->Mail->ErrorInfo);
|
||||
return;
|
||||
|
|
@ -995,7 +998,7 @@ EOT;
|
|||
$this->Mail->isHTML(true);
|
||||
|
||||
if (!$this->Mail->addStringEmbeddedImage(
|
||||
file_get_contents(realpath($this->INCLUDE_DIR . 'examples/images/phpmailer_mini.png')),
|
||||
file_get_contents(realpath($this->INCLUDE_DIR . '/examples/images/phpmailer_mini.png')),
|
||||
md5('phpmailer_mini.png').'@phpmailer.0',
|
||||
'', //intentionally empty name
|
||||
'base64',
|
||||
|
|
@ -1020,15 +1023,19 @@ EOT;
|
|||
$this->Mail->isHTML(true);
|
||||
|
||||
if (!$this->Mail->addAttachment(
|
||||
realpath($this->INCLUDE_DIR . 'examples/images/phpmailer_mini.png'),
|
||||
realpath($this->INCLUDE_DIR . '/examples/images/phpmailer_mini.png'),
|
||||
'phpmailer_mini.png'
|
||||
)
|
||||
)
|
||||
) {
|
||||
$this->assertTrue(false, $this->Mail->ErrorInfo);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->Mail->addAttachment(realpath($this->INCLUDE_DIR . 'examples/images/phpmailer.png'), 'phpmailer.png')) {
|
||||
if (!$this->Mail->addAttachment(
|
||||
realpath($this->INCLUDE_DIR . '/examples/images/phpmailer.png'),
|
||||
'phpmailer.png'
|
||||
)
|
||||
) {
|
||||
$this->assertTrue(false, $this->Mail->ErrorInfo);
|
||||
return;
|
||||
}
|
||||
|
|
@ -1042,14 +1049,14 @@ EOT;
|
|||
*/
|
||||
public function testEmbeddedImage()
|
||||
{
|
||||
$this->Mail->Body = 'Embedded Image: <img alt="phpmailer" src="'.
|
||||
$this->Mail->Body = 'Embedded Image: <img alt="phpmailer" src="' .
|
||||
'cid:my-attach">' .
|
||||
'Here is an image!';
|
||||
$this->Mail->Subject .= ': Embedded Image';
|
||||
$this->Mail->isHTML(true);
|
||||
|
||||
if (!$this->Mail->addEmbeddedImage(
|
||||
realpath($this->INCLUDE_DIR . 'examples/images/phpmailer.png'),
|
||||
realpath($this->INCLUDE_DIR . '/examples/images/phpmailer.png'),
|
||||
'my-attach',
|
||||
'phpmailer.png',
|
||||
'base64',
|
||||
|
|
@ -1079,7 +1086,7 @@ EOT;
|
|||
$this->Mail->isHTML(true);
|
||||
|
||||
if (!$this->Mail->addEmbeddedImage(
|
||||
realpath($this->INCLUDE_DIR . 'examples/images/phpmailer.png'),
|
||||
realpath($this->INCLUDE_DIR . '/examples/images/phpmailer.png'),
|
||||
'my-attach',
|
||||
'phpmailer.png',
|
||||
'base64',
|
||||
|
|
@ -1174,12 +1181,12 @@ EOT;
|
|||
//Only run if we have qmail installed
|
||||
if (file_exists('/var/qmail/bin/qmail-inject')) {
|
||||
$this->Mail->Body = 'Sending via qmail';
|
||||
$this->BuildBody();
|
||||
$this->buildBody();
|
||||
$subject = $this->Mail->Subject;
|
||||
|
||||
$this->Mail->Subject = $subject . ': qmail';
|
||||
$this->Mail->IsQmail();
|
||||
$this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
|
||||
$this->Mail->isQmail();
|
||||
$this->assertTrue($this->Mail->send(), $this->Mail->ErrorInfo);
|
||||
} else {
|
||||
$this->markTestSkipped('Qmail is not installed');
|
||||
}
|
||||
|
|
@ -1987,7 +1994,8 @@ EOT;
|
|||
{
|
||||
//Start a fake POP server
|
||||
$pid = shell_exec(
|
||||
'/usr/bin/nohup ' . $this->INCLUDE_DIR .
|
||||
'/usr/bin/nohup ' .
|
||||
$this->INCLUDE_DIR .
|
||||
'/test/runfakepopserver.sh 1100 >/dev/null 2>/dev/null & printf "%u" $!'
|
||||
);
|
||||
$this->pids[] = $pid;
|
||||
|
|
@ -2013,7 +2021,8 @@ EOT;
|
|||
//Start a fake POP server on a different port
|
||||
//so we don't inadvertently connect to the previous instance
|
||||
$pid = shell_exec(
|
||||
'/usr/bin/nohup '. $this->INCLUDE_DIR .
|
||||
'/usr/bin/nohup ' .
|
||||
$this->INCLUDE_DIR .
|
||||
'/test/runfakepopserver.sh 1101 >/dev/null 2>/dev/null & printf "%u" $!'
|
||||
);
|
||||
$this->pids[] = $pid;
|
||||
|
|
|
|||
Loading…
Reference in New Issue