Skip to content

Commit

Permalink
Merge branch 'master' into 5.4
Browse files Browse the repository at this point in the history
Bump version to 5.5
Clean up code generator
# Conflicts:
#	README.md
#	examples/send_file_upload.phps
#	src/SMTP.php
#	test/phpmailerTest.php
  • Loading branch information
Synchro committed Apr 7, 2016
1 parent 27501ac commit 33f82ab
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 57 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ php:
- 7.0
- 5.6
- 5.5
- 5.4
- hhvm
matrix:
allow_failures:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: [![Build Status](https://travis-ci.org/PHPMailer/PHPMailer.svg)](https://travis-ci.org/PHPMailer/PHPMailer)

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.4.0
5.5.0
8 changes: 4 additions & 4 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}
],
"require": {
"php": ">=5.4.0"
"php": ">=5.5.0"
},
"require-dev": {
"phpdocumentor/phpdocumentor": "2.*",
Expand Down
34 changes: 19 additions & 15 deletions examples/code_generator.phps
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
* revised, updated and corrected 27/02/2013
* by [email protected]
*/

namespace PHPMailer\PHPMailer;

require '../vendor/autoload.php';

$CFG['smtp_debug'] = 2; //0 == off, 1 for client output, 2 for client and server
Expand Down Expand Up @@ -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
Expand All @@ -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}";

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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'] .
Expand Down Expand Up @@ -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) {";
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion examples/mailing_list.phps
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions get_oauth_token.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/OAuthProvider/Google.php
Original file line number Diff line number Diff line change
@@ -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) <[email protected]>
Expand Down
6 changes: 3 additions & 3 deletions src/PHPMailer.php
Original file line number Diff line number Diff line change
@@ -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) <[email protected]>
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -1608,7 +1608,7 @@ public function smtpConnect($options = [])
*/
public function smtpClose()
{
if (is_a($this->smtp, 'SMTP')) {
if (!is_null($this->smtp)) {
if ($this->smtp->connected()) {
$this->smtp->quit();
$this->smtp->close();
Expand Down
2 changes: 1 addition & 1 deletion src/PHPMailerOAuth.php
Original file line number Diff line number Diff line change
@@ -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) <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion src/POP3.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class POP3
* @var string
* @access public
*/
public $Version = '5.4.0';
public $Version = '5.5.0';

/**
* Default POP3 port number.
Expand Down
2 changes: 1 addition & 1 deletion src/SMTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions test/phpmailerLangTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
/**
* PHPMailer - language file tests
*
* PHP version 5.4.0
*
* PHP version 5.5.0
* @package PHPMailer
* @author Marcus Bointon <[email protected]>
* @author Andy Prevost
Expand Down
Loading

0 comments on commit 33f82ab

Please sign in to comment.