0
0
mirror of https://github.com/PHPMailer/PHPMailer.git synced 2024-09-20 01:52:15 +02:00

Merge branch 'master' into xoauth

This commit is contained in:
Synchro 2016-01-07 20:38:58 +01:00
commit 7bb65f288b
10 changed files with 547 additions and 114 deletions

View File

@ -27,9 +27,9 @@
"phpunit/phpunit": "4.*"
},
"suggest": {
"league/oauth2-client": "Needed for XOAUTH2 authentication",
"hayageek/oauth2-yahoo": "Needed to use XOAUTH2 with Yahoo",
"stevenmaguire/oauth2-microsoft": "Needed to use XOAUTH2 with Microsoft services"
"league/oauth2-google": "Needed for Google XOAUTH2 authentication",
"hayageek/oauth2-yahoo": "Needed for Yahoo XOAUTH2 authentication",
"stevenmaguire/oauth2-microsoft": "Needed for Microsoft XOAUTH2 authentication"
},
"autoload": {
"psr-4": {

158
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "495451716a25ead2383e1ce84c91c8b5",
"hash": "9396a2c9b8520c9a2c65fd5a88639122",
"content-hash": "7a29f5f89d8a23ec75270d6dfcb13d2b",
"packages": [],
"packages-dev": [
@ -646,16 +646,16 @@
},
{
"name": "justinrainbow/json-schema",
"version": "1.5.0",
"version": "v1.6.0",
"source": {
"type": "git",
"url": "https://github.com/justinrainbow/json-schema.git",
"reference": "a4bee9f4b344b66e0a0d96c7afae1e92edf385fe"
"reference": "f9e27c3e202faf14fd581ef41355d83bb4b7eb7d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/a4bee9f4b344b66e0a0d96c7afae1e92edf385fe",
"reference": "a4bee9f4b344b66e0a0d96c7afae1e92edf385fe",
"url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/f9e27c3e202faf14fd581ef41355d83bb4b7eb7d",
"reference": "f9e27c3e202faf14fd581ef41355d83bb4b7eb7d",
"shasum": ""
},
"require": {
@ -708,7 +708,7 @@
"json",
"schema"
],
"time": "2015-09-08 22:28:04"
"time": "2016-01-06 14:37:04"
},
{
"name": "kherge/version",
@ -1553,16 +1553,16 @@
},
{
"name": "phpunit/phpunit",
"version": "4.8.19",
"version": "4.8.21",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "b2caaf8947aba5e002d42126723e9d69795f32b4"
"reference": "ea76b17bced0500a28098626b84eda12dbcf119c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b2caaf8947aba5e002d42126723e9d69795f32b4",
"reference": "b2caaf8947aba5e002d42126723e9d69795f32b4",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ea76b17bced0500a28098626b84eda12dbcf119c",
"reference": "ea76b17bced0500a28098626b84eda12dbcf119c",
"shasum": ""
},
"require": {
@ -1621,7 +1621,7 @@
"testing",
"xunit"
],
"time": "2015-11-30 08:18:59"
"time": "2015-12-12 07:45:58"
},
{
"name": "phpunit/phpunit-mock-objects",
@ -1831,23 +1831,23 @@
},
{
"name": "sebastian/diff",
"version": "1.4.0",
"version": "1.4.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/diff.git",
"reference": "2b0112e42c338afa9ad9dfeb94d66f6d84c2f828"
"reference": "13edfd8706462032c2f52b4b862974dd46b71c9e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/2b0112e42c338afa9ad9dfeb94d66f6d84c2f828",
"reference": "2b0112e42c338afa9ad9dfeb94d66f6d84c2f828",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/13edfd8706462032c2f52b4b862974dd46b71c9e",
"reference": "13edfd8706462032c2f52b4b862974dd46b71c9e",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"phpunit/phpunit": "~5"
"phpunit/phpunit": "~4.8"
},
"type": "library",
"extra": {
@ -1879,7 +1879,7 @@
"keywords": [
"diff"
],
"time": "2015-12-06 07:21:36"
"time": "2015-12-08 07:14:41"
},
{
"name": "sebastian/environment",
@ -2184,16 +2184,16 @@
},
{
"name": "symfony/config",
"version": "v2.8.0",
"version": "v2.8.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/config.git",
"reference": "f21c97aec1b5302d2dc0d17047ea8f4e4ff93aae"
"reference": "17d4b2e64ce1c6ba7caa040f14469b3c44d7f7d2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/config/zipball/f21c97aec1b5302d2dc0d17047ea8f4e4ff93aae",
"reference": "f21c97aec1b5302d2dc0d17047ea8f4e4ff93aae",
"url": "https://api.github.com/repos/symfony/config/zipball/17d4b2e64ce1c6ba7caa040f14469b3c44d7f7d2",
"reference": "17d4b2e64ce1c6ba7caa040f14469b3c44d7f7d2",
"shasum": ""
},
"require": {
@ -2230,20 +2230,20 @@
],
"description": "Symfony Config Component",
"homepage": "https://symfony.com",
"time": "2015-11-23 20:38:01"
"time": "2015-12-26 13:37:56"
},
{
"name": "symfony/console",
"version": "v2.8.0",
"version": "v2.8.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "d232bfc100dfd32b18ccbcab4bcc8f28697b7e41"
"reference": "2e06a5ccb19dcf9b89f1c6a677a39a8df773635a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/d232bfc100dfd32b18ccbcab4bcc8f28697b7e41",
"reference": "d232bfc100dfd32b18ccbcab4bcc8f28697b7e41",
"url": "https://api.github.com/repos/symfony/console/zipball/2e06a5ccb19dcf9b89f1c6a677a39a8df773635a",
"reference": "2e06a5ccb19dcf9b89f1c6a677a39a8df773635a",
"shasum": ""
},
"require": {
@ -2290,11 +2290,11 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2015-11-30 12:35:10"
"time": "2015-12-22 10:25:57"
},
{
"name": "symfony/event-dispatcher",
"version": "v2.8.0",
"version": "v2.8.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
@ -2354,16 +2354,16 @@
},
{
"name": "symfony/filesystem",
"version": "v3.0.0",
"version": "v3.0.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
"reference": "692d98d813e4ef314b9c22775c86ddbeb0f44884"
"reference": "c2e59d11dccd135dc8f00ee97f34fe1de842e70c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/692d98d813e4ef314b9c22775c86ddbeb0f44884",
"reference": "692d98d813e4ef314b9c22775c86ddbeb0f44884",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/c2e59d11dccd135dc8f00ee97f34fe1de842e70c",
"reference": "c2e59d11dccd135dc8f00ee97f34fe1de842e70c",
"shasum": ""
},
"require": {
@ -2399,20 +2399,20 @@
],
"description": "Symfony Filesystem Component",
"homepage": "https://symfony.com",
"time": "2015-11-23 10:41:47"
"time": "2015-12-22 10:39:06"
},
{
"name": "symfony/finder",
"version": "v2.8.0",
"version": "v2.8.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "ead9b07af4ba77b6507bee697396a5c79e633f08"
"reference": "dd41ae57f4f737be271d944a0cc5f5f21203a7c6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/ead9b07af4ba77b6507bee697396a5c79e633f08",
"reference": "ead9b07af4ba77b6507bee697396a5c79e633f08",
"url": "https://api.github.com/repos/symfony/finder/zipball/dd41ae57f4f737be271d944a0cc5f5f21203a7c6",
"reference": "dd41ae57f4f737be271d944a0cc5f5f21203a7c6",
"shasum": ""
},
"require": {
@ -2448,25 +2448,28 @@
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
"time": "2015-10-30 20:15:42"
"time": "2015-12-05 11:09:21"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.0.0",
"version": "v1.0.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "0b6a8940385311a24e060ec1fe35680e17c74497"
"reference": "49ff736bd5d41f45240cec77b44967d76e0c3d25"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/0b6a8940385311a24e060ec1fe35680e17c74497",
"reference": "0b6a8940385311a24e060ec1fe35680e17c74497",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/49ff736bd5d41f45240cec77b44967d76e0c3d25",
"reference": "49ff736bd5d41f45240cec77b44967d76e0c3d25",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"suggest": {
"ext-mbstring": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
@ -2504,20 +2507,20 @@
"portable",
"shim"
],
"time": "2015-11-04 20:28:58"
"time": "2015-11-20 09:19:13"
},
{
"name": "symfony/process",
"version": "v2.8.0",
"version": "v2.8.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "1b988a88e3551102f3c2d9e1d47a18c3a78d6312"
"reference": "62c254438b5040bc2217156e1570cf2206e8540c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/1b988a88e3551102f3c2d9e1d47a18c3a78d6312",
"reference": "1b988a88e3551102f3c2d9e1d47a18c3a78d6312",
"url": "https://api.github.com/repos/symfony/process/zipball/62c254438b5040bc2217156e1570cf2206e8540c",
"reference": "62c254438b5040bc2217156e1570cf2206e8540c",
"shasum": ""
},
"require": {
@ -2553,11 +2556,11 @@
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
"time": "2015-11-30 12:35:10"
"time": "2015-12-23 11:03:46"
},
{
"name": "symfony/stopwatch",
"version": "v2.8.0",
"version": "v2.8.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/stopwatch.git",
@ -2606,16 +2609,16 @@
},
{
"name": "symfony/translation",
"version": "v3.0.0",
"version": "v3.0.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation.git",
"reference": "7f14717150a7445f8475864d1235875dd04061fb"
"reference": "dff0867826a7068d673801b7522f8e2634016ef9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/7f14717150a7445f8475864d1235875dd04061fb",
"reference": "7f14717150a7445f8475864d1235875dd04061fb",
"url": "https://api.github.com/repos/symfony/translation/zipball/dff0867826a7068d673801b7522f8e2634016ef9",
"reference": "dff0867826a7068d673801b7522f8e2634016ef9",
"shasum": ""
},
"require": {
@ -2666,20 +2669,20 @@
],
"description": "Symfony Translation Component",
"homepage": "https://symfony.com",
"time": "2015-11-18 13:48:51"
"time": "2015-12-05 17:45:07"
},
{
"name": "symfony/validator",
"version": "v2.8.0",
"version": "v2.8.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/validator.git",
"reference": "8c42b96f5b23f0642c1a518addafcef8077154a2"
"reference": "ab56537745fe90066e23275f3dd8a002ff4e2c25"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/validator/zipball/8c42b96f5b23f0642c1a518addafcef8077154a2",
"reference": "8c42b96f5b23f0642c1a518addafcef8077154a2",
"url": "https://api.github.com/repos/symfony/validator/zipball/ab56537745fe90066e23275f3dd8a002ff4e2c25",
"reference": "ab56537745fe90066e23275f3dd8a002ff4e2c25",
"shasum": ""
},
"require": {
@ -2738,20 +2741,20 @@
],
"description": "Symfony Validator Component",
"homepage": "https://symfony.com",
"time": "2015-11-20 14:39:26"
"time": "2015-12-26 13:37:56"
},
{
"name": "symfony/yaml",
"version": "v3.0.0",
"version": "v3.0.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "177a015cb0e19ff4a49e0e2e2c5fc1c1bee07002"
"reference": "3df409958a646dad2bc5046c3fb671ee24a1a691"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/177a015cb0e19ff4a49e0e2e2c5fc1c1bee07002",
"reference": "177a015cb0e19ff4a49e0e2e2c5fc1c1bee07002",
"url": "https://api.github.com/repos/symfony/yaml/zipball/3df409958a646dad2bc5046c3fb671ee24a1a691",
"reference": "3df409958a646dad2bc5046c3fb671ee24a1a691",
"shasum": ""
},
"require": {
@ -2787,7 +2790,7 @@
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2015-11-30 12:36:17"
"time": "2015-12-26 13:39:53"
},
{
"name": "twig/twig",
@ -2972,16 +2975,16 @@
},
{
"name": "zendframework/zend-eventmanager",
"version": "2.5.2",
"version": "2.6.1",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-eventmanager.git",
"reference": "135af03d07fd048c322259aab6611d2be290475c"
"reference": "a03de810b99b0302059ab744c535d464b8dc4721"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zendframework/zend-eventmanager/zipball/135af03d07fd048c322259aab6611d2be290475c",
"reference": "135af03d07fd048c322259aab6611d2be290475c",
"url": "https://api.github.com/repos/zendframework/zend-eventmanager/zipball/a03de810b99b0302059ab744c535d464b8dc4721",
"reference": "a03de810b99b0302059ab744c535d464b8dc4721",
"shasum": ""
},
"require": {
@ -2989,14 +2992,15 @@
"zendframework/zend-stdlib": "~2.5"
},
"require-dev": {
"athletic/athletic": "dev-master",
"fabpot/php-cs-fixer": "1.7.*",
"phpunit/phpunit": "~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.5-dev",
"dev-develop": "2.6-dev"
"dev-master": "2.6-dev",
"dev-develop": "3.0-dev"
}
},
"autoload": {
@ -3013,7 +3017,7 @@
"eventmanager",
"zf2"
],
"time": "2015-07-16 19:00:49"
"time": "2015-10-06 11:53:40"
},
{
"name": "zendframework/zend-filter",
@ -3249,20 +3253,20 @@
},
{
"name": "zendframework/zend-math",
"version": "2.5.1",
"version": "2.5.2",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-math.git",
"reference": "9f02a1ac4d3374d3332c80f9215deec9c71558fc"
"reference": "2648ee3cce39aa3876788c837e3b58f198dc8a78"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zendframework/zend-math/zipball/9f02a1ac4d3374d3332c80f9215deec9c71558fc",
"reference": "9f02a1ac4d3374d3332c80f9215deec9c71558fc",
"url": "https://api.github.com/repos/zendframework/zend-math/zipball/2648ee3cce39aa3876788c837e3b58f198dc8a78",
"reference": "2648ee3cce39aa3876788c837e3b58f198dc8a78",
"shasum": ""
},
"require": {
"php": ">=5.3.23"
"php": ">=5.5"
},
"require-dev": {
"fabpot/php-cs-fixer": "1.7.*",
@ -3297,7 +3301,7 @@
"math",
"zf2"
],
"time": "2015-06-03 15:32:02"
"time": "2015-12-17 15:31:58"
},
{
"name": "zendframework/zend-serializer",

View File

@ -0,0 +1,93 @@
<?php
namespace PHPMailer\PHPMailer;
require '../vendor/autoload.php';
class SMTP_lowmemory extends SMTP {
public function data($msg_data)
{
//This will use the standard timelimit
if (!$this->sendCommand('DATA', 'DATA', 354)) {
return false;
}
/* The server is ready to accept data!
* According to rfc821 we should not send more than 1000 characters on a single line (including the CRLF)
* so we will break the data up into lines by \r and/or \n then if needed we will break each of those into
* smaller lines to fit within the limit.
* We will also look for lines that start with a '.' and prepend an additional '.'.
* NOTE: this does not count towards line-length limit.
*/
// Normalize line breaks
$msg_data = str_replace(["\r\n", "\r"], "\n", $msg_data);
/* To distinguish between a complete RFC822 message and a plain message body, we check if the first field
* of the first line (':' separated) does not contain a space then it _should_ be a header and we will
* process all lines before a blank line as headers.
*/
$firstline = substr($msg_data, 0, strcspn($msg_data, "\n", 0));
$field = substr($firstline, 0, strpos($firstline, ':'));
$in_headers = false;
if (!empty($field) && strpos($field, ' ') === false) {
$in_headers = true;
}
$offset = 0;
$len = strlen($msg_data);
while ($offset < $len) {
//Get position of next line break
$linelen = strcspn($msg_data, "\n", $offset);
//Get the next line
$line = substr($msg_data, $offset, $linelen);
//Remember where we have got to
$offset += ($linelen + 1);
$lines_out = [];
if ($in_headers and $line == '') {
$in_headers = false;
}
//We need to break this line up into several smaller lines
//This is a small micro-optimisation: isset($str[$len]) is equivalent to (strlen($str) > $len)
while (isset($line[self::MAX_LINE_LENGTH])) {
//Working backwards, try to find a space within the last MAX_LINE_LENGTH chars of the line to break on
//so as to avoid breaking in the middle of a word
$pos = strrpos(substr($line, 0, self::MAX_LINE_LENGTH), ' ');
//Deliberately matches both false and 0
if (!$pos) {
//No nice break found, add a hard break
$pos = self::MAX_LINE_LENGTH - 1;
$lines_out[] = substr($line, 0, $pos);
$line = substr($line, $pos);
} else {
//Break at the found point
$lines_out[] = substr($line, 0, $pos);
//Move along by the amount we dealt with
$line = substr($line, $pos + 1);
}
//If processing headers add a LWSP-char to the front of new line RFC822 section 3.1.1
if ($in_headers) {
$line = "\t" . $line;
}
}
$lines_out[] = $line;
//Send the lines to the server
foreach ($lines_out as $line_out) {
//RFC2821 section 4.5.2
if (!empty($line_out) and $line_out[0] == '.') {
$line_out = '.' . $line_out;
}
$this->client_send($line_out . self::CRLF);
}
}
//Message data has been sent, complete the command
//Increase timelimit for end of DATA command
$savetimelimit = $this->Timelimit;
$this->Timelimit = $this->Timelimit * 2;
$result = $this->sendCommand('DATA END', '.', 250);
//Restore timelimit
$this->Timelimit = $savetimelimit;
return $result;
}
}

View File

@ -1,51 +1,166 @@
<?php
/**
* This example shows settings to use when sending via Google's Gmail servers.
* This example shows settings to use when sending via Google's Gmail servers using XOAUTH2.
*/
namespace PHPMailer\PHPMailer;
//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have access to that
date_default_timezone_set('Etc/UTC');
require '../PHPMailerAutoload.php';
//Load dependencies from composer
//If this causes an error, run 'composer install'
require '../vendor/autoload.php';
//Create a new Gmail-specific PHPMailer instance
$mail = new PHPMailerOAuthGoogle;
//Create a new PHPMailer instance
$mail = new PHPMailerOAuth;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
$mail->SMTPDebug = 0;
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;
//Ask for HTML-friendly debug output
//$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = 'smtp.gmail.com';
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = 587;
//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = 'tls';
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Set AuthType
//Set AuthTYpe
$mail->AuthType = 'XOAUTH2';
//User Email to use for SMTP authentication - Who authorised to access Google mail
$mail->oauthUserEmail = 'sender@gmail.com';
//UserEmail to use for SMTP authentication - Use the same Email used in Google Developer Console
$mail->oauthUserEmail = "marcus.bointon@gmail.com";
//Obtained From Google Developer Console
$mail->oauthClientId = '{YOUR_APP_CLIENT_ID}';
$mail->oauthClientId = "237644427849-g8d0pnkd1jh3idcjdbopvkse2hvj0tdp.apps.googleusercontent.com";
//Obtained From Google Developer Console
$mail->oauthClientSecret = '{YOUR_APP_CLIENT_SECRET}';
$mail->oauthClientSecret = "mklHhrns6eF-qjwuiLpSB4DL";
//Obtained By running get_oauth_token.php after setting up APP in Google Developer Console.
//Set Redirect URI in Developer Console as [https/http]://<yourdomain>/<folder>/get_oauth_token.php
// eg: http://localhost/phpmail/get_oauth_token.php
$mail->oauthRefreshToken = '{OAUTH_TOKEN_FROM_GOOGLE}';
$mail->setFrom('sender@gmail.com', 'test test');
$mail->addAddress('whoto@example.com', 'John Doe');
$mail->Subject = 'PHPMailer GMail XOAUTH2 SMTP test';
//Set Redirect URI in Developer Console as [https/http]://<yourdomain>/<folder>/get_oauth_token.php
// eg: http://localhost/phpmail/get_oauth_token.php
$mail->oauthRefreshToken = "1/7Jt8_RHX86Pk09VTfQd4O_ZqKbmuV7HpMNz-rqJ4KdQMEudVrK5jSpoR30zcRFq6";
$mail->SMTPOptions = [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
]
];
//Set who the message is to be sent from
$mail->setFrom('marcus.bointon@gmail.com', 'First Last');
//Set who the message is to be sent to
$mail->addAddress('marcus@synchromedia.co.uk', 'John Doe');
//Set the subject line
$mail->Subject = 'PHPMailer GMail SMTP test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
//send the message, check for errors
if (!$mail->send()) {
echo 'Mailer Error: ' . $mail->ErrorInfo;
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo 'Message sent!';
echo "Message sent!";
}

View File

@ -0,0 +1,96 @@
<?php
/**
* This example shows settings to use when sending via Outlook/Microsoft Live servers using XOAUTH2.
*/
namespace PHPMailer\PHPMailer;
date_default_timezone_set('Etc/UTC');
require '../vendor/autoload.php';
//Load dependencies from composer
//If this causes an error, run 'composer install'
require '../vendor/autoload.php';
//Create a new Microsoft-specific PHPMailer instance
$mail = new PHPMailerOAuthMicrosoft;
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Host = 'smtp-mail.outlook.com';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
//Set AuthType
$mail->AuthType = 'XOAUTH2';
//User Email to use for SMTP authentication - Who authorised to access Outlook mail
$mail->oauthUserEmail = "sender@hotmail.com";
//Obtained From https://account.live.com/developers/applications/index
$mail->oauthClientId = "{YOUR_CLIENT_ID}";
//Obtained From https://account.live.com/developers/applications/index
$mail->oauthClientSecret = "{YOUR_CLIENT_SECRET}";
//Obtained By running get_oauth_token.php
$mail->oauthRefreshToken = "{OAUTH_REFRESH_TOKEN}";
$mail->setFrom('sender@hotmail.com', 'Test');
$mail->addAddress('receiver@gmail.com', 'Test');
$mail->Subject = 'PHPMailer hotmail XOAUTH2 SMTP test';
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}

View File

@ -0,0 +1,94 @@
<?php
/**
* This example shows settings to use when sending via Yahoo servers using XOAUTH2.
*/
namespace PHPMailer\PHPMailer;
date_default_timezone_set('Etc/UTC');
require '../vendor/autoload.php';
//Load dependencies from composer
//If this causes an error, run 'composer install'
require '../vendor/autoload.php';
//Create a new Yahoo-specific PHPMailer instance
$mail = new PHPMailerOAuthYahoo;
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Host = 'smtp.mail.yahoo.com';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
//Set AuthType
$mail->AuthType = 'XOAUTH2';
//User Email to use for SMTP authentication - Who authorised to send Yahoo mail
$mail->oauthUserEmail = 'sender@yahoo.com';
//Obtained From https://developer.yahoo.com/apps/
$mail->oauthClientId = '{YAHOO_CLIENT_ID}';
//Obtained From https://developer.yahoo.com/apps/
$mail->oauthClientSecret = '{CLIENT_SECRET}'';
// eg: http://localhost/phpmail/get_oauth_token.php
$mail->oauthRefreshToken = '{REFRESH_TOKEN}';
$mail->setFrom('sender@yahoo.com', 'test');
$mail->addAddress('receiver@gmail.com', 'test');
$mail->Subject = 'PHPMailer Yahoo XOAUTH2 SMTP test';
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
if (!$mail->send()) {
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message sent!';
}

View File

@ -41,12 +41,6 @@ if (!isset($_GET['code']) && !isset($_GET['provider'])) {
exit;
}
/**
* Added a new class for getting the Refresh Token with right scopes
* as the OAuth-Client for Google from GitHub didnot provide setting the
* scope out of the box
*/
namespace League\OAuth2\Client\Provider;
require 'vendor/autoload.php';

View File

@ -0,0 +1,26 @@
<?php
/**
* Sinhala PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer
* @author Senasum Rajapalsha <senasum@live.com>
*/
$PHPMAILER_LANG['authenticate'] = 'SMTP fodihls: l%shd lrúh fkdyl .';
$PHPMAILER_LANG['connect_host'] = 'SMTP fodihls: iïnkao l, fkdyl.';
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP fodihls: o;a; Ndr .; fkdyl.';
$PHPMAILER_LANG['empty_message'] = 'ysia mksúvhls';
$PHPMAILER_LANG['encoding'] = 'iqrlaYs; njg m;a lrï: ';
$PHPMAILER_LANG['execute'] = 'l%shd lrúh fkdyl: ';
$PHPMAILER_LANG['file_access'] = 'f.dkqj fj; ,.d úh fkdyl: ';
$PHPMAILER_LANG['file_open'] = 'f.dkqj újD; fkdfj: ';
$PHPMAILER_LANG['from_failed'] = 'f*d¾uh jrÈh: ';
$PHPMAILER_LANG['instantiate'] = 'jyd l, hq;= fj.';
$PHPMAILER_LANG['invalid_address'] = 'smskh jrÈh: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' mksúv lre fkd.,mS.';
$PHPMAILER_LANG['provide_address'] = ',smskh w;=,a lrkak.';
$PHPMAILER_LANG['recipients_failed'] = 'SMTP fodihls: mksúvh ,.d l, fkdyl: ';
$PHPMAILER_LANG['signing'] = 'w;=,a úh fkdyl: ';
$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP iïnkao l, fkdyl.';
$PHPMAILER_LANG['smtp_error'] = 'SMTP fodihls:: ';
$PHPMAILER_LANG['variable_set'] = 'úp,h ilia lr fkdu;: ';
$PHPMAILER_LANG['extension_missing'] = 'l%shd lrúh fkdyl: ';

View File

@ -840,7 +840,7 @@ class PHPMailer
$name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
if (($pos = strrpos($address, '@')) === false) {
// At-sign is misssing.
$error_message = $this->lang('invalid_address') . $address;
$error_message = $this->lang('invalid_address') . " (addAnAddress $kind): $address";
$this->setError($error_message);
$this->edebug($error_message);
if ($this->exceptions) {
@ -890,7 +890,7 @@ class PHPMailer
return false;
}
if (!$this->validateAddress($address)) {
$error_message = $this->lang('invalid_address') . $address;
$error_message = $this->lang('invalid_address') . " (addAnAddress $kind): $address";
$this->setError($error_message);
$this->edebug($error_message);
if ($this->exceptions) {
@ -984,7 +984,7 @@ class PHPMailer
if (($pos = strrpos($address, '@')) === false or
(!$this->has8bitChars(substr($address, ++$pos)) or !$this->idnSupported()) and
!$this->validateAddress($address)) {
$error_message = $this->lang('invalid_address') . $address;
$error_message = $this->lang('invalid_address') . " (setFrom) $address";
$this->setError($error_message);
$this->edebug($error_message);
if ($this->exceptions) {
@ -1197,7 +1197,7 @@ class PHPMailer
}
$this->$address_kind = $this->punyencodeAddress($this->$address_kind);
if (!$this->validateAddress($this->$address_kind)) {
$error_message = $this->lang('invalid_address') . $this->$address_kind;
$error_message = $this->lang('invalid_address') . ' (punyEncode) ' . $this->$address_kind;
$this->setError($error_message);
$this->edebug($error_message);
if ($this->exceptions) {
@ -1208,7 +1208,7 @@ class PHPMailer
}
// Set whether the message is multipart/alternative
if (!empty($this->AltBody)) {
if ($this->alternativeExists()) {
$this->ContentType = 'multipart/alternative';
}
@ -1954,7 +1954,7 @@ class PHPMailer
$result .= $this->headerLine('Subject', $this->encodeHeader($this->secureHeader($this->Subject)));
}
if ($this->MessageID != '') {
if ('' != $this->MessageID and preg_match('/^<.*@.*>$/', $this->MessageID)) {
$this->lastMessageID = $this->MessageID;
} else {
$this->lastMessageID = sprintf('<%s@%s>', $this->uniqueid, $this->serverHostname());
@ -3279,7 +3279,7 @@ class PHPMailer
// Convert all message body line breaks to CRLF, makes quoted-printable encoding work much better
$this->Body = $this->normalizeBreaks($message);
$this->AltBody = $this->normalizeBreaks($this->html2text($message, $advanced));
if (empty($this->AltBody)) {
if (!$this->alternativeExists()) {
$this->AltBody = 'To view this email message, open it in a program that understands HTML!' .
self::CRLF . self::CRLF;
}

View File

@ -1759,7 +1759,18 @@ EOT;
$this->buildBody();
$this->Mail->preSend();
$lastid = $this->Mail->getLastMessageID();
$this->assertEquals($lastid, $id, 'Custom Message ID mismatch');
$this->assertNotEquals($lastid, $id, 'Invalid Message ID allowed');
$id = '<'.md5(12345).'@example.com>';
$this->Mail->MessageID = $id;
$this->buildBody();
$this->Mail->preSend();
$lastid = $this->Mail->getLastMessageID();
$this->assertEquals($lastid, $id, 'Custom Message ID not used');
$this->Mail->MessageID = '';
$this->buildBody();
$this->Mail->preSend();
$lastid = $this->Mail->getLastMessageID();
$this->assertRegExp('/^<.*@.*>$/', $lastid, 'Invalid default Message ID');
}
/**