Merge remote-tracking branch 'remotes/upstream/5.4' into xoauth

# Conflicts:
#	composer.json
#	composer.lock
#	get_oauth_token.php
This commit is contained in:
Synchro 2015-12-07 22:37:30 +01:00
commit dffac3a0f5
10 changed files with 184 additions and 588 deletions

View File

@ -18,19 +18,17 @@ before_script:
- sudo service postfix stop
- smtp-sink -d "%d.%H.%M.%S" localhost:2500 1000 &
- mkdir -p build/logs
- cd test
- cp testbootstrap-dist.php testbootstrap.php
- chmod +x fakesendmail.sh
- cp test/testbootstrap-dist.php test/testbootstrap.php
- chmod +x test/fakesendmail.sh
- sudo mkdir -p /var/qmail/bin
- sudo cp fakesendmail.sh /var/qmail/bin/sendmail
- sudo cp fakesendmail.sh /usr/sbin/sendmail
- sudo cp test/fakesendmail.sh /var/qmail/bin/sendmail
- sudo cp test/fakesendmail.sh /usr/sbin/sendmail
- |
if [[ $TRAVIS_PHP_VERSION != "hhv"* ]]; then
echo 'sendmail_path = "/usr/sbin/sendmail -t -i "' > $(php --ini|grep -m 1 "ini files in:"|cut -d ":" -f 2)/sendmail.ini
fi
- pwd
script:
- phpunit --configuration ../travis.phpunit.xml.dist --bootstrap ../vendor/autoload.php
- ./vendor/bin/phpunit --configuration ./travis.phpunit.xml.dist --bootstrap ./vendor/autoload.php
after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover ../build/logs/clover.xml

View File

@ -14,6 +14,8 @@ This is a major update that breaks backwards compatibility.
To avoid version confusion, this release is called **5.4**, **not 5.3**!
* Fix gmail XOAUTH2 scope, thanks to @sherryl4george
## Version 5.2.14 (Nov 1st 2015)
* Allow addresses with IDN (Internationalized Domain Name) in PHP 5.3+, thanks to @fbonzon
* Allow access to POP3 errors

View File

@ -20,17 +20,14 @@
}
],
"require": {
"php": ">=5.4.0",
"league/oauth2-google": "^1.0",
"hayageek/oauth2-yahoo": "^2.0",
"stevenmaguire/oauth2-microsoft": "^0.2.0"
"php": ">=5.4.0"
},
"require-dev": {
"phpdocumentor/phpdocumentor": "2.*",
"phpunit/phpunit": "4.*"
},
"suggest": {
"league/oauth2-google": "Needed to use XOAUTH2 with Goole Gmail",
"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"
},

557
composer.lock generated
View File

@ -4,544 +4,9 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "a3b58b03d342cf999d3795eca7e463b6",
"content-hash": "2d44974fc89cc800c9af9e89463f0ae2",
"packages": [
{
"name": "guzzlehttp/guzzle",
"version": "6.1.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "66fd14b4d0b8f2389eaf37c5458608c7cb793a81"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/66fd14b4d0b8f2389eaf37c5458608c7cb793a81",
"reference": "66fd14b4d0b8f2389eaf37c5458608c7cb793a81",
"shasum": ""
},
"require": {
"guzzlehttp/promises": "~1.0",
"guzzlehttp/psr7": "~1.1",
"php": ">=5.5.0"
},
"require-dev": {
"ext-curl": "*",
"phpunit/phpunit": "~4.0",
"psr/log": "~1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "6.1-dev"
}
},
"autoload": {
"files": [
"src/functions_include.php"
],
"psr-4": {
"GuzzleHttp\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "Guzzle is a PHP HTTP client library",
"homepage": "http://guzzlephp.org/",
"keywords": [
"client",
"curl",
"framework",
"http",
"http client",
"rest",
"web service"
],
"time": "2015-09-08 17:36:26"
},
{
"name": "guzzlehttp/promises",
"version": "1.0.3",
"source": {
"type": "git",
"url": "https://github.com/guzzle/promises.git",
"reference": "b1e1c0d55f8083c71eda2c28c12a228d708294ea"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/promises/zipball/b1e1c0d55f8083c71eda2c28c12a228d708294ea",
"reference": "b1e1c0d55f8083c71eda2c28c12a228d708294ea",
"shasum": ""
},
"require": {
"php": ">=5.5.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Promise\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "Guzzle promises library",
"keywords": [
"promise"
],
"time": "2015-10-15 22:28:00"
},
{
"name": "guzzlehttp/psr7",
"version": "1.2.1",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
"reference": "4d0bdbe1206df7440219ce14c972aa57cc5e4982"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/4d0bdbe1206df7440219ce14c972aa57cc5e4982",
"reference": "4d0bdbe1206df7440219ce14c972aa57cc5e4982",
"shasum": ""
},
"require": {
"php": ">=5.4.0",
"psr/http-message": "~1.0"
},
"provide": {
"psr/http-message-implementation": "1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Psr7\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "PSR-7 message implementation",
"keywords": [
"http",
"message",
"stream",
"uri"
],
"time": "2015-11-03 01:34:55"
},
{
"name": "hayageek/oauth2-yahoo",
"version": "2.0.4",
"source": {
"type": "git",
"url": "https://github.com/hayageek/oauth2-yahoo.git",
"reference": "f29c7faa7e4449c70b7aeac53c3ea9ebf7f52245"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/hayageek/oauth2-yahoo/zipball/f29c7faa7e4449c70b7aeac53c3ea9ebf7f52245",
"reference": "f29c7faa7e4449c70b7aeac53c3ea9ebf7f52245",
"shasum": ""
},
"require": {
"league/oauth2-client": "^1.0"
},
"require-dev": {
"mockery/mockery": "~0.9",
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "~2.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Hayageek\\OAuth2\\Client\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ravishanker Kusuma",
"email": "hayageek@gmail.com",
"homepage": "http://hayageek.com"
}
],
"description": "Yahoo OAuth 2.0 Client Provider for The PHP League OAuth2-Client",
"keywords": [
"Authentication",
"authorization",
"client",
"oauth",
"oauth2",
"yahoo"
],
"time": "2015-09-23 18:08:39"
},
{
"name": "ircmaxell/random-lib",
"version": "v1.1.0",
"source": {
"type": "git",
"url": "https://github.com/ircmaxell/RandomLib.git",
"reference": "13efa4368bb2ac88bb3b1459b487d907de4dbf7c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ircmaxell/RandomLib/zipball/13efa4368bb2ac88bb3b1459b487d907de4dbf7c",
"reference": "13efa4368bb2ac88bb3b1459b487d907de4dbf7c",
"shasum": ""
},
"require": {
"ircmaxell/security-lib": "1.0.*@dev",
"php": ">=5.3.2"
},
"require-dev": {
"mikey179/vfsstream": "1.1.*",
"phpunit/phpunit": "3.7.*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-0": {
"RandomLib": "lib"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Anthony Ferrara",
"email": "ircmaxell@ircmaxell.com",
"homepage": "http://blog.ircmaxell.com"
}
],
"description": "A Library For Generating Secure Random Numbers",
"homepage": "https://github.com/ircmaxell/RandomLib",
"keywords": [
"cryptography",
"random",
"random-numbers",
"random-strings"
],
"time": "2015-01-15 16:31:45"
},
{
"name": "ircmaxell/security-lib",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/ircmaxell/SecurityLib.git",
"reference": "80934de3c482dcafb46b5756e59ebece082b6dc7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ircmaxell/SecurityLib/zipball/80934de3c482dcafb46b5756e59ebece082b6dc7",
"reference": "80934de3c482dcafb46b5756e59ebece082b6dc7",
"shasum": ""
},
"require": {
"php": ">=5.3.2"
},
"require-dev": {
"mikey179/vfsstream": "1.1.*"
},
"type": "library",
"autoload": {
"psr-0": {
"SecurityLib": "lib"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Anthony Ferrara",
"email": "ircmaxell@ircmaxell.com",
"homepage": "http://blog.ircmaxell.com"
}
],
"description": "A Base Security Library",
"homepage": "https://github.com/ircmaxell/PHP-SecurityLib",
"time": "2013-04-30 18:00:34"
},
{
"name": "league/oauth2-client",
"version": "1.0.2",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/oauth2-client.git",
"reference": "32d94d0ffc846b7f0fd9a115a7b0795a47a2d11c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/oauth2-client/zipball/32d94d0ffc846b7f0fd9a115a7b0795a47a2d11c",
"reference": "32d94d0ffc846b7f0fd9a115a7b0795a47a2d11c",
"shasum": ""
},
"require": {
"ext-curl": "*",
"guzzlehttp/guzzle": "~6.0",
"ircmaxell/random-lib": "~1.1",
"php": ">=5.5.0"
},
"require-dev": {
"jakub-onderka/php-parallel-lint": "0.8.*",
"mockery/mockery": "~0.9",
"phpunit/phpunit": "~4.0",
"satooshi/php-coveralls": "0.6.*",
"squizlabs/php_codesniffer": "~2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"League\\OAuth2\\Client\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Alex Bilbie",
"email": "hello@alexbilbie.com",
"homepage": "http://www.alexbilbie.com",
"role": "Developer"
}
],
"description": "OAuth 2.0 Client Library",
"keywords": [
"Authentication",
"SSO",
"authorization",
"identity",
"idp",
"oauth",
"oauth2",
"single sign on"
],
"time": "2015-09-22 18:26:19"
},
{
"name": "league/oauth2-google",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/oauth2-google.git",
"reference": "4788fcef5cf0fdb65e0322c3f4d4632d8f1f3e82"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/oauth2-google/zipball/4788fcef5cf0fdb65e0322c3f4d4632d8f1f3e82",
"reference": "4788fcef5cf0fdb65e0322c3f4d4632d8f1f3e82",
"shasum": ""
},
"require": {
"league/oauth2-client": "~1.0"
},
"require-dev": {
"mockery/mockery": "~0.9",
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "~2.0"
},
"type": "library",
"autoload": {
"psr-4": {
"League\\OAuth2\\Client\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Woody Gilk",
"email": "woody.gilk@gmail.com",
"homepage": "http://shadowhand.me"
}
],
"description": "Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client",
"keywords": [
"Authentication",
"authorization",
"client",
"google",
"oauth",
"oauth2"
],
"time": "2015-08-28 18:33:30"
},
{
"name": "psr/http-message",
"version": "1.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-message.git",
"reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/85d63699f0dbedb190bbd4b0d2b9dc707ea4c298",
"reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for HTTP messages",
"keywords": [
"http",
"http-message",
"psr",
"psr-7",
"request",
"response"
],
"time": "2015-05-04 20:22:00"
},
{
"name": "stevenmaguire/oauth2-microsoft",
"version": "0.2.0",
"source": {
"type": "git",
"url": "https://github.com/stevenmaguire/oauth2-microsoft.git",
"reference": "1141315e8e878cf2c9847193a675fcde0a157a8c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/stevenmaguire/oauth2-microsoft/zipball/1141315e8e878cf2c9847193a675fcde0a157a8c",
"reference": "1141315e8e878cf2c9847193a675fcde0a157a8c",
"shasum": ""
},
"require": {
"league/oauth2-client": "~1.0",
"php": ">=5.5.0"
},
"require-dev": {
"mockery/mockery": "~0.9",
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "~2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Stevenmaguire\\OAuth2\\Client\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Steven Maguire",
"email": "stevenmaguire@gmail.com",
"homepage": "https://github.com/stevenmaguire"
}
],
"description": "Microsoft OAuth 2.0 Client Provider for The PHP League OAuth2-Client",
"keywords": [
"authorisation",
"authorization",
"client",
"microsoft",
"oauth",
"oauth2"
],
"time": "2015-08-20 14:08:56"
}
],
"hash": "a429c95dbdbbd148875d5439f2573a6c",
"content-hash": "b9b55ea56a3d102706244316ea5e3ede",
"packages": [],
"packages-dev": [
{
"name": "cilex/cilex",
@ -2088,16 +1553,16 @@
},
{
"name": "phpunit/phpunit",
"version": "4.8.16",
"version": "4.7.7",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "625f8c345606ed0f3a141dfb88f4116f0e22978e"
"reference": "9b97f9d807b862c2de2a36e86690000801c85724"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/625f8c345606ed0f3a141dfb88f4116f0e22978e",
"reference": "625f8c345606ed0f3a141dfb88f4116f0e22978e",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9b97f9d807b862c2de2a36e86690000801c85724",
"reference": "9b97f9d807b862c2de2a36e86690000801c85724",
"shasum": ""
},
"require": {
@ -2107,7 +1572,7 @@
"ext-reflection": "*",
"ext-spl": "*",
"php": ">=5.3.3",
"phpspec/prophecy": "^1.3.1",
"phpspec/prophecy": "~1.3,>=1.3.1",
"phpunit/php-code-coverage": "~2.1",
"phpunit/php-file-iterator": "~1.4",
"phpunit/php-text-template": "~1.2",
@ -2115,7 +1580,7 @@
"phpunit/phpunit-mock-objects": "~2.3",
"sebastian/comparator": "~1.1",
"sebastian/diff": "~1.2",
"sebastian/environment": "~1.3",
"sebastian/environment": "~1.2",
"sebastian/exporter": "~1.2",
"sebastian/global-state": "~1.0",
"sebastian/version": "~1.0",
@ -2130,7 +1595,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.8.x-dev"
"dev-master": "4.7.x-dev"
}
},
"autoload": {
@ -2156,7 +1621,7 @@
"testing",
"xunit"
],
"time": "2015-10-23 06:48:33"
"time": "2015-07-13 11:28:34"
},
{
"name": "phpunit/phpunit-mock-objects",

View File

@ -41,8 +41,21 @@ 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';
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
use League\OAuth2\Client\Token\AccessToken;
use League\OAuth2\Client\Tool\BearerAuthorizationTrait;
use Psr\Http\Message\ResponseInterface;
session_start();
$providerName = '';
@ -70,6 +83,102 @@ $provider = new $providerClass(
'offline'
);
class Google extends AbstractProvider
{
use BearerAuthorizationTrait;
const ACCESS_TOKEN_RESOURCE_OWNER_ID = 'id';
/**
* @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;
/**
* @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',
];
}
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);
}
}
if (!isset($_GET['code'])) {
// If we don't have an authorization code then get one
$authUrl = $provider->getAuthorizationUrl($options);

View File

@ -2102,8 +2102,9 @@ class PHPMailer
$altBodyEncoding = '7bit';
$altBodyCharSet = 'us-ascii';
}
//If lines are too long, change to quoted-printable transfer encoding
if (self::hasLineLongerThanMax($this->AltBody)) {
//If lines are too long, and we're not already using an encoding that will shorten them,
//change to quoted-printable transfer encoding
if ('base64' != $altBodyEncoding and self::hasLineLongerThanMax($this->AltBody)) {
$altBodyEncoding = 'quoted-printable';
}
//Use this as a preamble in all multipart message types

View File

@ -14,8 +14,6 @@
namespace PHPMailer\PHPMailer;
require_once '../vendor/autoload.php';
/**
* PHPMailer - PHP email transport unit test class
* Performs authentication tests

View File

@ -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
@ -64,8 +64,9 @@ class PHPMailerTest extends \PHPUnit_Framework_TestCase
*/
public function setUp()
{
if (file_exists('./testbootstrap.php')) {
include './testbootstrap.php'; //Overrides go in here
$this->INCLUDE_DIR = dirname(__DIR__); //Default to the dir above the test dir, i.e. the project home dir
if (file_exists($this->INCLUDE_DIR . '/test/testbootstrap.php')) {
include $this->INCLUDE_DIR . '/test/testbootstrap.php'; //Overrides go in here
}
$this->Mail = new PHPMailer;
$this->Mail->SMTPDebug = 3; //Full debug output
@ -296,7 +297,7 @@ class PHPMailerTest extends \PHPUnit_Framework_TestCase
public function testBootstrap()
{
$this->assertTrue(
file_exists('./testbootstrap.php'),
file_exists($this->INCLUDE_DIR . '/test/testbootstrap.php'),
'Test config params missing - copy testbootstrap.php to testbootstrap-dist.php and change as appropriate'
);
}
@ -723,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('../examples/images/phpmailer.png')) {
if (!$this->Mail->addAttachment($this->INCLUDE_DIR.'/examples/images/phpmailer.png')) {
$this->assertTrue(false, $this->Mail->ErrorInfo);
return;
}
@ -824,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('../examples/contents.html');
$content = file_get_contents($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!
@ -834,7 +835,7 @@ EOT;
"ISO-8859-1",
mb_detect_encoding($content, "UTF-8, ISO-8859-1, ISO-8859-15", true)
),
'../examples'
$this->INCLUDE_DIR.'/examples'
);
$this->buildBody();
$this->assertTrue(
@ -898,7 +899,7 @@ EOT;
</html>
EOT;
$this->Mail->addEmbeddedImage(
'../examples/images/phpmailer.png',
$this->INCLUDE_DIR .'/examples/images/phpmailer.png',
'my-attach',
'phpmailer.png',
'base64',
@ -934,12 +935,12 @@ EOT;
*/
public function testMsgHTML()
{
$message = file_get_contents('../examples/contentsutf8.html');
$message = file_get_contents($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, '../examples');
$this->Mail->msgHTML($message, $this->INCLUDE_DIR .'/examples');
$this->Mail->Subject .= ': msgHTML';
$this->assertNotEmpty($this->Mail->Body, 'Body not set by msgHTML');
@ -948,9 +949,13 @@ EOT;
//Again, using a custom HTML to text converter
$this->Mail->AltBody = '';
$this->Mail->msgHTML($message, '../examples', function ($html) {
return strtoupper(strip_tags($html));
});
$this->Mail->msgHTML(
$message,
$this->INCLUDE_DIR .'/examples',
function ($html) {
return strtoupper(strip_tags($html));
}
);
$this->Mail->Subject .= ' + custom html2text';
$this->assertNotEmpty($this->Mail->AltBody, 'Custom AltBody not set by msgHTML');
@ -966,7 +971,11 @@ EOT;
$this->Mail->Subject .= ': HTML + Attachment';
$this->Mail->isHTML(true);
if (!$this->Mail->addAttachment('../examples/images/phpmailer_mini.png', 'phpmailer_mini.png')) {
if (!$this->Mail->addAttachment(
$this->INCLUDE_DIR . '/examples/images/phpmailer_mini.png',
'phpmailer_mini.png'
)
) {
$this->assertTrue(false, $this->Mail->ErrorInfo);
return;
}
@ -988,7 +997,7 @@ EOT;
$this->Mail->isHTML(true);
if (!$this->Mail->addStringEmbeddedImage(
file_get_contents('../examples/images/phpmailer_mini.png'),
file_get_contents($this->INCLUDE_DIR .'/examples/images/phpmailer_mini.png'),
md5('phpmailer_mini.png').'@phpmailer.0',
'', //intentionally empty name
'base64',
@ -1012,12 +1021,16 @@ EOT;
$this->Mail->Subject .= ': HTML + multiple Attachment';
$this->Mail->isHTML(true);
if (!$this->Mail->addAttachment('../examples/images/phpmailer_mini.png', 'phpmailer_mini.png')) {
if (!$this->Mail->addAttachment(
$this->INCLUDE_DIR . '/examples/images/phpmailer_mini.png',
'phpmailer_mini.png'
)
) {
$this->assertTrue(false, $this->Mail->ErrorInfo);
return;
}
if (!$this->Mail->addAttachment('../examples/images/phpmailer.png', 'phpmailer.png')) {
if (!$this->Mail->addAttachment($this->INCLUDE_DIR .'/examples/images/phpmailer.png', 'phpmailer.png')) {
$this->assertTrue(false, $this->Mail->ErrorInfo);
return;
}
@ -1037,7 +1050,7 @@ EOT;
$this->Mail->isHTML(true);
if (!$this->Mail->addEmbeddedImage(
'../examples/images/phpmailer.png',
$this->INCLUDE_DIR .'/examples/images/phpmailer.png',
'my-attach',
'phpmailer.png',
'base64',
@ -1066,7 +1079,7 @@ EOT;
$this->Mail->isHTML(true);
if (!$this->Mail->addEmbeddedImage(
'../examples/images/phpmailer.png',
$this->INCLUDE_DIR .'/examples/images/phpmailer.png',
'my-attach',
'phpmailer.png',
'base64',
@ -1944,33 +1957,41 @@ EOT;
/**
* Use a fake POP3 server to test POP-before-SMTP auth.
* With a known-good login
* @group pop3
*/
public function testPopBeforeSmtpGood()
{
//Start a fake POP server
$pid = shell_exec('nohup ./runfakepopserver.sh >/dev/null 2>/dev/null & printf "%u" $!');
$pid = shell_exec(
'/usr/bin/nohup ' . $this->INCLUDE_DIR .
'/test/runfakepopserver.sh 1100 >/dev/null 2>/dev/null & printf "%u" $!'
);
$this->pids[] = $pid;
sleep(2);
sleep(1);
//Test a known-good login
$this->assertTrue(
POP3::popBeforeSmtp('localhost', 1100, 10, 'user', 'test', $this->Mail->SMTPDebug),
'POP before SMTP failed'
);
//Kill the fake server
shell_exec('kill -TERM ' . escapeshellarg($pid));
//Kill the fake server, don't care if it fails
@shell_exec('kill -TERM ' . escapeshellarg($pid));
sleep(2);
}
/**
* Use a fake POP3 server to test POP-before-SMTP auth.
* With a known-bad login
* @group pop3
*/
public function testPopBeforeSmtpBad()
{
//Start a fake POP server on a different port
//so we don't inadvertently connect to the previous instance
$pid = shell_exec('nohup ./runfakepopserver.sh 1101 >/dev/null 2>/dev/null & printf "%u" $!');
$pid = shell_exec(
'/usr/bin/nohup '. $this->INCLUDE_DIR .
'/test/runfakepopserver.sh 1101 >/dev/null 2>/dev/null & printf "%u" $!'
);
$this->pids[] = $pid;
sleep(2);
@ -1979,7 +2000,8 @@ EOT;
POP3::popBeforeSmtp('localhost', 1101, 10, 'user', 'xxx', $this->Mail->SMTPDebug),
'POP before SMTP should have failed'
);
shell_exec('kill -TERM ' . escapeshellarg($pid));
//Kill the fake server, don't care if it fails
@shell_exec('kill -TERM ' . escapeshellarg($pid));
sleep(2);
}
@ -2016,7 +2038,7 @@ EOT;
* which is probably more useful if you run these tests a lot
* <html>
* <body>
* <h3>phpmailer Unit Test</h3>
* <h3>PHPMailer Unit Test</h3>
* By entering a SMTP hostname it will automatically perform tests with SMTP.
*
* <form name="phpmailer_unit" action=__FILE__ method="get">

View File

@ -1,10 +1,13 @@
#!/usr/bin/env bash
set -xv
# Run the fake pop server from bash
# Idea from http://blog.ale-re.net/2007/09/ipersimple-remote-shell-with-netcat.html
# Defaults to port 1100 so it can be run by unpriv users and not clash with a real server
# Optionally, pass in a port number as the first arg
rm -f fifo
mkfifo fifo
nc -l ${1:-1100} <fifo |bash ./fakepopserver.sh >fifo
rm fifo

View File

@ -19,6 +19,7 @@
<groups>
<exclude>
<group>languages</group>
<group>pop3</group>
</exclude>
</groups>
<logging>