diff --git a/.travis.yml b/.travis.yml
index f16d8264..6eacab3a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,7 +3,6 @@ php:
- 7.0
- 5.6
- 5.5
- - 5.4
- hhvm
matrix:
allow_failures:
diff --git a/README.md b/README.md
index f52de0cb..aeb87a13 100644
--- a/README.md
+++ b/README.md
@@ -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)
diff --git a/VERSION b/VERSION
index 1e20ec35..c7ba1e87 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-5.4.0
\ No newline at end of file
+5.5.0
\ No newline at end of file
diff --git a/changelog.md b/changelog.md
index eebb66e5..ff40e6ba 100644
--- a/changelog.md
+++ b/changelog.md
@@ -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:
diff --git a/examples/code_generator.phps b/examples/code_generator.phps
index 2d998e20..f1ae8b51 100644
--- a/examples/code_generator.phps
+++ b/examples/code_generator.phps
@@ -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 = "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}";
";
- 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) {
diff --git a/examples/mailing_list.phps b/examples/mailing_list.phps
index 9e13c15d..c115b2e0 100644
--- a/examples/mailing_list.phps
+++ b/examples/mailing_list.phps
@@ -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
diff --git a/examples/send_file_upload.phps b/examples/send_file_upload.phps
index 42c4509e..bd15e8b3 100644
--- a/examples/send_file_upload.phps
+++ b/examples/send_file_upload.phps
@@ -22,19 +22,19 @@ if (array_key_exists('userfile', $_FILES)) {
// Attach the uploaded file
$mail->addAttachment($uploadfile, 'My uploaded file');
if (!$mail->send()) {
- $msg = "Mailer Error: " . $mail->ErrorInfo;
+ $msg .= "Mailer Error: " . $mail->ErrorInfo;
} else {
- $msg = "Message sent!";
+ $msg .= "Message sent!";
}
} else {
- $msg = 'Failed to move file to ' . $uploadfile;
+ $msg .= 'Failed to move file to ' . $uploadfile;
}
}
?>
-
+
PHPMailer Upload
diff --git a/examples/send_multiple_file_upload.phps b/examples/send_multiple_file_upload.phps
new file mode 100644
index 00000000..ddb76146
--- /dev/null
+++ b/examples/send_multiple_file_upload.phps
@@ -0,0 +1,51 @@
+setFrom('from@example.com', 'First Last');
+ $mail->addAddress('whoto@example.com', 'John Doe');
+ $mail->Subject = 'PHPMailer file sender';
+ $mail->msgHTML('My message body');
+ //Attach multiple files one by one
+ for ($ct = 0; $ct < count($_FILES['userfile']['tmp_name']); $ct++) {
+ $uploadfile = tempnam(sys_get_temp_dir(), sha1($_FILES['userfile']['name'][$ct]));
+ $filename = $_FILES['userfile']['name'][$ct];
+ if (move_uploaded_file($_FILES['userfile']['tmp_name'][$ct], $uploadfile)) {
+ $mail->addAttachment($uploadfile, $filename);
+ } else {
+ $msg .= 'Failed to move file to ' . $uploadfile;
+ }
+ }
+ if (!$mail->send()) {
+ $msg .= "Mailer Error: " . $mail->ErrorInfo;
+ } else {
+ $msg .= "Message sent!";
+ }
+}
+?>
+
+
+
+
+ PHPMailer Upload
+
+
+
+
+
+
+
diff --git a/examples/smtp_check.phps b/examples/smtp_check.phps
index bc3046ea..b15b3f36 100644
--- a/examples/smtp_check.phps
+++ b/examples/smtp_check.phps
@@ -18,24 +18,39 @@ $smtp = new SMTP;
$smtp->do_debug = SMTP::DEBUG_CONNECTION;
try {
-//Connect to an SMTP server
- if ($smtp->connect('mail.example.com', 25)) {
- //Say hello
- if ($smtp->hello('localhost')) { //Put your host name in here
- //Authenticate
- if ($smtp->authenticate('username', 'password')) {
- echo "Connected ok!";
- } else {
- throw new Exception('Authentication failed: ' . $smtp->getLastReply());
- }
- } else {
- throw new Exception('HELO failed: '. $smtp->getLastReply());
- }
- } else {
+ //Connect to an SMTP server
+ if (!$smtp->connect('mail.example.com', 25)) {
throw new Exception('Connect failed');
}
+ //Say hello
+ if (!$smtp->hello(gethostname())) {
+ throw new Exception('EHLO failed: ' . $smtp->getError()['error']);
+ }
+ //Get the list of ESMTP services the server offers
+ $e = $smtp->getServerExtList();
+ //If server can do TLS encryption, use it
+ if (array_key_exists('STARTTLS', $e)) {
+ $tlsok = $smtp->startTLS();
+ if (!$tlsok) {
+ throw new Exception('Failed to start encryption: ' . $smtp->getError()['error']);
+ }
+ //Repeat EHLO after STARTTLS
+ if (!$smtp->hello(gethostname())) {
+ throw new Exception('EHLO (2) failed: ' . $smtp->getError()['error']);
+ }
+ //Get new capabilities list, which will usually now include AUTH if it didn't before
+ $e = $smtp->getServerExtList();
+ }
+ //If server supports authentication, do it (even if no encryption)
+ if (array_key_exists('AUTH', $e)) {
+ if ($smtp->authenticate('username', 'password')) {
+ echo "Connected ok!";
+ } else {
+ throw new Exception('Authentication failed: ' . $smtp->getError()['error']);
+ }
+ }
} catch (Exception $e) {
- echo 'SMTP error: '. $e->getMessage(), "\n";
+ echo 'SMTP error: ' . $e->getMessage(), "\n";
}
//Whatever happened, close the connection.
$smtp->quit(true);
diff --git a/get_oauth_token.php b/get_oauth_token.php
index e9192067..4b58138c 100644
--- a/get_oauth_token.php
+++ b/get_oauth_token.php
@@ -1,116 +1,154 @@
- * @author Jim Jagielski (jimjag)
- * @author Andy Prevost (codeworxtech)
- * @author Brent R. Matzelle (original founder)
- * @copyright 2012 - 2015 Marcus Bointon
- * @copyright 2010 - 2012 Jim Jagielski
- * @copyright 2004 - 2009 Andy Prevost
- * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
- * @note This program is distributed in the hope that it will be useful - WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.
- */
-/**
- * Get an OAuth2 token from an OAuth2 provider.
+ * Get an OAuth2 token from Google.
* * Install this script on your server so that it's accessible
* as [https/http]:////get_oauth_token.php
- * e.g.: http://localhost/phpmailer/get_oauth_token.php
+ * e.g.: http://localhost/phpmail/get_oauth_token.php
* * Ensure dependencies are installed with 'composer install'
- * * Set up an app in your Google/Yahoo/Microsoft account
+ * * Set up an app in your Google developer console
* * 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 and run the script again.
+ * 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.5 or later
+ * PHP Version 5.5
*/
-namespace PHPMailer\PHPMailer;
-
-// Aliases for League Provider Classes that may be used
-// Make sure you have added these to your composer.json and run `composer install`
-use League\OAuth2\Client\Provider\Google;
-use Hayageek\OAuth2\Client\Provider\Yahoo;
-use Stevenmaguire\OAuth2\Client\Provider\Microsoft;
-
-if (!isset($_GET['code']) && !isset($_GET['provider'])) {
-?>
-
-Select Provider:
-Google
-Yahoo
-Microsoft/Outlook/Hotmail/Live/Office365
-
- $clientId,
- 'clientSecret' => $clientSecret,
- 'redirectUri' => $redirectUri,
- 'accessType' => 'offline'
-];
+ const ACCESS_TOKEN_RESOURCE_OWNER_ID = 'id';
-$options = [];
+ /**
+ * @var string If set, this will be sent to google as the "access_type" parameter.
+ * @link https://developers.google.com/accounts/docs/OAuth2WebServer#offline
+ */
+ protected $accessType;
-switch ($providerName) {
- case 'Google':
- $provider = new Google($params);
- $options = [
- 'scope' => [
- 'https://mail.google.com/'
- ]
+ /**
+ * @var string If set, this will be sent to google as the "hd" parameter.
+ * @link https://developers.google.com/accounts/docs/OAuth2Login#hd-param
+ */
+ protected $hostedDomain;
+
+ /**
+ * @var string If set, this will be sent to google as the "scope" parameter.
+ * @link https://developers.google.com/gmail/api/auth/scopes
+ */
+ protected $scope;
+
+ public function getBaseAuthorizationUrl()
+ {
+ return 'https://accounts.google.com/o/oauth2/auth';
+ }
+
+ public function getBaseAccessTokenUrl(array $params)
+ {
+ return 'https://accounts.google.com/o/oauth2/token';
+ }
+
+ public function getResourceOwnerDetailsUrl(AccessToken $token)
+ {
+ return ' ';
+ }
+
+ protected function getAuthorizationParameters(array $options)
+ {
+ if (is_array($this->scope)) {
+ $separator = $this->getScopeSeparator();
+ $this->scope = implode($separator, $this->scope);
+ }
+
+ $params = array_merge(
+ parent::getAuthorizationParameters($options),
+ array_filter([
+ 'hd' => $this->hostedDomain,
+ 'access_type' => $this->accessType,
+ 'scope' => $this->scope,
+ // if the user is logged in with more than one account ask which one to use for the login!
+ 'authuser' => '-1'
+ ])
+ );
+ return $params;
+ }
+
+ protected function getDefaultScopes()
+ {
+ return [
+ 'email',
+ 'openid',
+ 'profile',
];
- break;
- case 'Yahoo':
- $provider = new Yahoo($params);
- break;
- case 'Microsoft':
- $provider = new Microsoft($params);
- break;
+ }
+
+ protected function getScopeSeparator()
+ {
+ return ' ';
+ }
+
+ protected function checkResponse(ResponseInterface $response, $data)
+ {
+ if (!empty($data['error'])) {
+ $code = 0;
+ $error = $data['error'];
+
+ if (is_array($error)) {
+ $code = $error['code'];
+ $error = $error['message'];
+ }
+
+ throw new IdentityProviderException($error, $code, $data);
+ }
+ }
+
+ protected function createResourceOwner(array $response, AccessToken $token)
+ {
+ return new GoogleUser($response);
+ }
}
+
+//Set Redirect URI in Developer Console as [https/http]:////get_oauth_token.php
+$provider = new Google(
+ array(
+ 'clientId' => $clientId,
+ 'clientSecret' => $clientSecret,
+ 'redirectUri' => $redirectUri,
+ 'scope' => array('https://mail.google.com/'),
+ 'accessType' => 'offline'
+ )
+);
+
if (!isset($_GET['code'])) {
// If we don't have an authorization code then get one
- $authUrl = $provider->getAuthorizationUrl($options);
+ $authUrl = $provider->getAuthorizationUrl();
$_SESSION['oauth2state'] = $provider->getState();
header('Location: ' . $authUrl);
exit;
// Check given state against previously stored one to mitigate CSRF attack
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {
unset($_SESSION['oauth2state']);
- unset($_SESSION['provider']);
exit('Invalid state');
} else {
- unset($_SESSION['provider']);
// Try to get an access token (using the authorization code grant)
$token = $provider->getAccessToken(
'authorization_code',
@@ -118,7 +156,7 @@ if (!isset($_GET['code'])) {
'code' => $_GET['code']
]
);
- // Use this to interact with an API on the users behalf
+
// Use this to get a new access token if the old one expires
echo 'Refresh Token: ' . $token->getRefreshToken();
}
diff --git a/src/PHPMailer.php b/src/PHPMailer.php
index 662eb4ad..b490432b 100644
--- a/src/PHPMailer.php
+++ b/src/PHPMailer.php
@@ -1,7 +1,7 @@
@@ -323,6 +323,7 @@ class PHPMailer
/**
* Whether to split multiple to addresses into multiple messages
* or send them all in one message.
+ * Only supported in `mail` and `sendmail` transports, not in SMTP.
* @var boolean
*/
public $SingleTo = false;
@@ -578,7 +579,7 @@ class PHPMailer
/**
* The PHPMailer Version number.
*/
- const VERSION = '5.4.0';
+ const VERSION = '5.5.0';
/**
* Error severity: message only, continue processing.
@@ -621,9 +622,7 @@ class PHPMailer
public function __destruct()
{
//Close any open SMTP connection nicely
- if ($this->Mailer == 'smtp') {
- $this->smtpClose();
- }
+ $this->smtpClose();
}
/**
@@ -1601,7 +1600,7 @@ class PHPMailer
*/
public function smtpClose()
{
- if ($this->smtp !== null) {
+ if (!is_null($this->smtp)) {
if ($this->smtp->connected()) {
$this->smtp->quit();
$this->smtp->close();
diff --git a/src/POP3.php b/src/POP3.php
index 97ca7cbe..dcfb0526 100644
--- a/src/POP3.php
+++ b/src/POP3.php
@@ -36,7 +36,7 @@ class POP3
* @var string
* @access public
*/
- public $Version = '5.4.0';
+ public $Version = '5.5.0';
/**
* Default POP3 port number.
diff --git a/src/SMTP.php b/src/SMTP.php
index 730ded67..7cf98caa 100644
--- a/src/SMTP.php
+++ b/src/SMTP.php
@@ -8,7 +8,7 @@
* @author Jim Jagielski (jimjag)
* @author Andy Prevost (codeworxtech)
* @author Brent R. Matzelle (original founder)
- * @copyright 2012 - 2015 Marcus Bointon
+ * @copyright 2012 - 2016 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
@@ -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.
@@ -661,7 +661,7 @@ class SMTP
protected function parseHelloFields($type)
{
$this->server_caps = [];
- $lines = explode("\n", $this->last_reply);
+ $lines = explode("\n", $this->helo_rply);
foreach ($lines as $n => $s) {
//First 4 chars contain response code followed by - or space
diff --git a/test/phpmailerLangTest.php b/test/phpmailerLangTest.php
index 22d460c6..c4858f57 100644
--- a/test/phpmailerLangTest.php
+++ b/test/phpmailerLangTest.php
@@ -2,8 +2,7 @@
/**
* PHPMailer - language file tests
*
- * PHP version 5.4.0
- *
+ * PHP version 5.5.0
* @package PHPMailer
* @author Marcus Bointon
* @author Andy Prevost
diff --git a/test/phpmailerTest.php b/test/phpmailerTest.php
index af8d02b5..79597272 100644
--- a/test/phpmailerTest.php
+++ b/test/phpmailerTest.php
@@ -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
* @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($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($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)
),
- $this->INCLUDE_DIR.'/examples'
+ realpath($this->INCLUDE_DIR . '/examples')
);
$this->buildBody();
$this->assertTrue(
@@ -899,7 +899,7 @@ EOT;
EOT;
$this->Mail->addEmbeddedImage(
- $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($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, $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');
@@ -951,7 +952,7 @@ EOT;
$this->Mail->AltBody = '';
$this->Mail->msgHTML(
$message,
- $this->INCLUDE_DIR .'/examples',
+ realpath($this->INCLUDE_DIR .'/examples'),
function ($html) {
return strtoupper(strip_tags($html));
}
@@ -972,7 +973,7 @@ EOT;
$this->Mail->isHTML(true);
if (!$this->Mail->addAttachment(
- $this->INCLUDE_DIR . '/examples/images/phpmailer_mini.png',
+ realpath($this->INCLUDE_DIR . '/examples/images/phpmailer_mini.png'),
'phpmailer_mini.png'
)
) {
@@ -997,7 +998,7 @@ EOT;
$this->Mail->isHTML(true);
if (!$this->Mail->addStringEmbeddedImage(
- file_get_contents($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',
@@ -1022,7 +1023,7 @@ EOT;
$this->Mail->isHTML(true);
if (!$this->Mail->addAttachment(
- $this->INCLUDE_DIR . '/examples/images/phpmailer_mini.png',
+ realpath($this->INCLUDE_DIR . '/examples/images/phpmailer_mini.png'),
'phpmailer_mini.png'
)
) {
@@ -1030,7 +1031,11 @@ EOT;
return;
}
- if (!$this->Mail->addAttachment($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;
}
@@ -1044,13 +1049,14 @@ EOT;
*/
public function testEmbeddedImage()
{
- $this->Mail->Body = 'Embedded Image:
' .
+ $this->Mail->Body = 'Embedded Image:
' .
'Here is an image!';
$this->Mail->Subject .= ': Embedded Image';
$this->Mail->isHTML(true);
if (!$this->Mail->addEmbeddedImage(
- $this->INCLUDE_DIR .'/examples/images/phpmailer.png',
+ realpath($this->INCLUDE_DIR . '/examples/images/phpmailer.png'),
'my-attach',
'phpmailer.png',
'base64',
@@ -1073,13 +1079,14 @@ EOT;
*/
public function testMultiEmbeddedImage()
{
- $this->Mail->Body = 'Embedded Image:
' .
+ $this->Mail->Body = 'Embedded Image:
' .
'Here is an image!';
$this->Mail->Subject .= ': Embedded Image + Attachment';
$this->Mail->isHTML(true);
if (!$this->Mail->addEmbeddedImage(
- $this->INCLUDE_DIR .'/examples/images/phpmailer.png',
+ realpath($this->INCLUDE_DIR . '/examples/images/phpmailer.png'),
'my-attach',
'phpmailer.png',
'base64',
@@ -1133,11 +1140,6 @@ EOT;
$this->buildBody();
$this->assertTrue($this->Mail->send(), $this->Mail->ErrorInfo);
- if (is_writable('.')) {
- file_put_contents('message.txt', $this->Mail->createHeader() . $this->Mail->createBody());
- } else {
- $this->assertTrue(false, 'Could not write local file - check permissions');
- }
}
/**
@@ -1179,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');
}
@@ -1567,8 +1569,8 @@ EOT;
"private_key_type" => OPENSSL_KEYTYPE_RSA,
];
$password = 'password';
- $certfile = 'certfile.txt';
- $keyfile = 'keyfile.txt';
+ $certfile = 'certfile.pem';
+ $keyfile = 'keyfile.pem';
//Make a new key pair
$pk = openssl_pkey_new($keyconfig);
@@ -1992,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;
@@ -2009,8 +2012,8 @@ EOT;
}
/**
- * Use a fake POP3 server to test POP-before-SMTP auth.
- * With a known-bad login
+ * Use a fake POP3 server to test POP-before-SMTP auth
+ * with a known-bad login.
* @group pop3
*/
public function testPopBeforeSmtpBad()
@@ -2018,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;