- Adds SMTP mailer + tests
- Adjusts Mailer router - Changes sender/recipient email in tests - Adds SwiftMailer composer dependency
This commit is contained in:
@@ -6,7 +6,8 @@
|
|||||||
"cerdic/css-tidy": "*",
|
"cerdic/css-tidy": "*",
|
||||||
"sunra/php-simple-html-dom-parser": "*",
|
"sunra/php-simple-html-dom-parser": "*",
|
||||||
"tburry/pquery": "*",
|
"tburry/pquery": "*",
|
||||||
"j4mie/paris": "1.5.4"
|
"j4mie/paris": "1.5.4",
|
||||||
|
"swiftmailer/swiftmailer": "^5.4"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"codeception/codeception": "*",
|
"codeception/codeception": "*",
|
||||||
|
108
composer.lock
generated
108
composer.lock
generated
@@ -4,8 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"hash": "0e2b177a6de46c3a1263386f1b803faf",
|
"hash": "8c4bd23de3a24fd6cb46185e6ea8c8ba",
|
||||||
"content-hash": "a8f94cd2f301434c7bac1f383d9f975f",
|
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "cerdic/css-tidy",
|
"name": "cerdic/css-tidy",
|
||||||
@@ -261,6 +260,59 @@
|
|||||||
],
|
],
|
||||||
"time": "2013-05-04 14:32:03"
|
"time": "2013-05-04 14:32:03"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "swiftmailer/swiftmailer",
|
||||||
|
"version": "v5.4.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/swiftmailer/swiftmailer.git",
|
||||||
|
"reference": "0697e6aa65c83edf97bb0f23d8763f94e3f11421"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/0697e6aa65c83edf97bb0f23d8763f94e3f11421",
|
||||||
|
"reference": "0697e6aa65c83edf97bb0f23d8763f94e3f11421",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3.3"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"mockery/mockery": "~0.9.1,<0.9.4"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "5.4-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"lib/swift_required.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Chris Corbyn"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Fabien Potencier",
|
||||||
|
"email": "fabien@symfony.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Swiftmailer, free feature-rich PHP mailer",
|
||||||
|
"homepage": "http://swiftmailer.org",
|
||||||
|
"keywords": [
|
||||||
|
"email",
|
||||||
|
"mail",
|
||||||
|
"mailer"
|
||||||
|
],
|
||||||
|
"time": "2015-06-06 14:19:39"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "tburry/pquery",
|
"name": "tburry/pquery",
|
||||||
"version": "v1.1.0",
|
"version": "v1.1.0",
|
||||||
@@ -378,23 +430,23 @@
|
|||||||
"packages-dev": [
|
"packages-dev": [
|
||||||
{
|
{
|
||||||
"name": "codeception/codeception",
|
"name": "codeception/codeception",
|
||||||
"version": "2.1.3",
|
"version": "2.1.2",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/Codeception/Codeception.git",
|
"url": "https://github.com/Codeception/Codeception.git",
|
||||||
"reference": "cd810cb78a869408602e17271f9b7368b09a7ca8"
|
"reference": "521adbb2ee34e9debdd8508a2c41ab2b5c2f042b"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/Codeception/Codeception/zipball/cd810cb78a869408602e17271f9b7368b09a7ca8",
|
"url": "https://api.github.com/repos/Codeception/Codeception/zipball/521adbb2ee34e9debdd8508a2c41ab2b5c2f042b",
|
||||||
"reference": "cd810cb78a869408602e17271f9b7368b09a7ca8",
|
"reference": "521adbb2ee34e9debdd8508a2c41ab2b5c2f042b",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"ext-mbstring": "*",
|
"ext-mbstring": "*",
|
||||||
"facebook/webdriver": ">=1.0.1",
|
"facebook/webdriver": ">=1.0.1",
|
||||||
"guzzlehttp/guzzle": ">=4.1.4 <7.0",
|
"guzzlehttp/guzzle": ">=4.0|<7.0",
|
||||||
"guzzlehttp/psr7": "~1.0",
|
"guzzlehttp/psr7": "~1.0",
|
||||||
"php": ">=5.4.0",
|
"php": ">=5.4.0",
|
||||||
"phpunit/phpunit": "~4.8.0",
|
"phpunit/phpunit": "~4.8.0",
|
||||||
@@ -454,7 +506,7 @@
|
|||||||
"functional testing",
|
"functional testing",
|
||||||
"unit testing"
|
"unit testing"
|
||||||
],
|
],
|
||||||
"time": "2015-10-02 09:38:59"
|
"time": "2015-08-09 13:48:55"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "codeception/verify",
|
"name": "codeception/verify",
|
||||||
@@ -981,16 +1033,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/php-code-coverage",
|
"name": "phpunit/php-code-coverage",
|
||||||
"version": "2.2.4",
|
"version": "2.2.3",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
||||||
"reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979"
|
"reference": "ef1ca6835468857944d5c3b48fa503d5554cff2f"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979",
|
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ef1ca6835468857944d5c3b48fa503d5554cff2f",
|
||||||
"reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979",
|
"reference": "ef1ca6835468857944d5c3b48fa503d5554cff2f",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -1039,7 +1091,7 @@
|
|||||||
"testing",
|
"testing",
|
||||||
"xunit"
|
"xunit"
|
||||||
],
|
],
|
||||||
"time": "2015-10-06 15:47:00"
|
"time": "2015-09-14 06:51:16"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/php-file-iterator",
|
"name": "phpunit/php-file-iterator",
|
||||||
@@ -1221,16 +1273,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/phpunit",
|
"name": "phpunit/phpunit",
|
||||||
"version": "4.8.11",
|
"version": "4.8.9",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||||
"reference": "bdd199472410fd7e32751f9c814c7e06f2c21bd5"
|
"reference": "73fad41adb5b7bc3a494bb930d90648df1d5e74b"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/bdd199472410fd7e32751f9c814c7e06f2c21bd5",
|
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/73fad41adb5b7bc3a494bb930d90648df1d5e74b",
|
||||||
"reference": "bdd199472410fd7e32751f9c814c7e06f2c21bd5",
|
"reference": "73fad41adb5b7bc3a494bb930d90648df1d5e74b",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -1289,20 +1341,20 @@
|
|||||||
"testing",
|
"testing",
|
||||||
"xunit"
|
"xunit"
|
||||||
],
|
],
|
||||||
"time": "2015-10-07 10:39:46"
|
"time": "2015-09-20 12:56:44"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/phpunit-mock-objects",
|
"name": "phpunit/phpunit-mock-objects",
|
||||||
"version": "2.3.8",
|
"version": "2.3.7",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
|
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
|
||||||
"reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983"
|
"reference": "5e2645ad49d196e020b85598d7c97e482725786a"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983",
|
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/5e2645ad49d196e020b85598d7c97e482725786a",
|
||||||
"reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983",
|
"reference": "5e2645ad49d196e020b85598d7c97e482725786a",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -1345,7 +1397,7 @@
|
|||||||
"mock",
|
"mock",
|
||||||
"xunit"
|
"xunit"
|
||||||
],
|
],
|
||||||
"time": "2015-10-02 06:51:40"
|
"time": "2015-08-19 09:14:08"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "psr/http-message",
|
"name": "psr/http-message",
|
||||||
@@ -1681,16 +1733,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/global-state",
|
"name": "sebastian/global-state",
|
||||||
"version": "1.1.0",
|
"version": "1.0.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/global-state.git",
|
"url": "https://github.com/sebastianbergmann/global-state.git",
|
||||||
"reference": "23af31f402993cfd94e99cbc4b782e9a78eb0e97"
|
"reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/23af31f402993cfd94e99cbc4b782e9a78eb0e97",
|
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/c7428acdb62ece0a45e6306f1ae85e1c05b09c01",
|
||||||
"reference": "23af31f402993cfd94e99cbc4b782e9a78eb0e97",
|
"reference": "c7428acdb62ece0a45e6306f1ae85e1c05b09c01",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -1728,7 +1780,7 @@
|
|||||||
"keywords": [
|
"keywords": [
|
||||||
"global state"
|
"global state"
|
||||||
],
|
],
|
||||||
"time": "2015-06-21 15:11:22"
|
"time": "2014-10-06 09:23:50"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/recursion-context",
|
"name": "sebastian/recursion-context",
|
||||||
|
@@ -34,6 +34,9 @@ class Mailer {
|
|||||||
case 'SendGrid':
|
case 'SendGrid':
|
||||||
$mailer = new $this->mailer['class']($this->mailer['api_key'], $this->fromEmail, $this->fromName);
|
$mailer = new $this->mailer['class']($this->mailer['api_key'], $this->fromEmail, $this->fromName);
|
||||||
break;
|
break;
|
||||||
|
case 'SMTP':
|
||||||
|
$mailer = new $this->mailer['class']($this->mailer['host'], $this->mailer['port'], $this->mailer['authentication'], $this->mailer['encryption'], $this->fromEmail, $this->fromName);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return $mailer;
|
return $mailer;
|
||||||
}
|
}
|
||||||
@@ -78,13 +81,24 @@ class Mailer {
|
|||||||
'name' => 'SendGrid',
|
'name' => 'SendGrid',
|
||||||
'type' => 'API',
|
'type' => 'API',
|
||||||
'api_key' => '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'
|
'api_key' => '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'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'name' => 'SMTP',
|
||||||
|
'type' => 'SMTP',
|
||||||
|
'host' => 'email-smtp.us-west-2.amazonaws.com',
|
||||||
|
'port' => 587,
|
||||||
|
'authentication' => array(
|
||||||
|
'login' => 'AKIAIGPBLH6JWG5VCBQQ',
|
||||||
|
'password' => 'AudVHXHaYkvr54veCzqiqOxDiMMyfQW3/V6F1tYzGXY3'
|
||||||
|
),
|
||||||
|
'encryption' => 'tls'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$mailer = $mailers[array_rand($mailers)];
|
$mailer = $mailers[array_rand($mailers)];
|
||||||
return array_merge($mailer, array('class' => sprintf('MailPoet\\Mailer\\%s\\%s', $mailer['type'], $mailer['name'])));
|
return array_merge($mailer, array('class' => sprintf('MailPoet\\Mailer\\%s\\%s', $mailer['type'], $mailer['name'])));
|
||||||
}
|
}
|
||||||
if($setting === 'from_name') return 'Sender';
|
if($setting === 'from_name') return 'Sender';
|
||||||
if($setting === 'from_address') return 'mailpoet-phoenix-test@mailinator.com';
|
if($setting === 'from_address') return 'staff@mailpoet.com';
|
||||||
return Setting::where('name', $setting)
|
return Setting::where('name', $setting)
|
||||||
->findOne()->value;
|
->findOne()->value;
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,7 @@ class ElasticEmailCest {
|
|||||||
'type' => 'API',
|
'type' => 'API',
|
||||||
'api_key' => '997f1f7f-41de-4d7f-a8cb-86c8481370fa'
|
'api_key' => '997f1f7f-41de-4d7f-a8cb-86c8481370fa'
|
||||||
);
|
);
|
||||||
$this->fromEmail = 'do-not-reply@mailpoet.com';
|
$this->fromEmail = 'staff@mailpoet.com';
|
||||||
$this->fromName = 'Sender';
|
$this->fromName = 'Sender';
|
||||||
$this->mailer = new ElasticEmail($this->settings['api_key'], $this->fromEmail, $this->fromName);
|
$this->mailer = new ElasticEmail($this->settings['api_key'], $this->fromEmail, $this->fromName);
|
||||||
$this->mailer->subscriber = 'Recipient <mailpoet-phoenix-test@mailinator.com>';
|
$this->mailer->subscriber = 'Recipient <mailpoet-phoenix-test@mailinator.com>';
|
||||||
|
@@ -10,7 +10,7 @@ class MailGunCest {
|
|||||||
'api_key' => 'key-6cf5g5qjzenk-7nodj44gdt8phe6vam2',
|
'api_key' => 'key-6cf5g5qjzenk-7nodj44gdt8phe6vam2',
|
||||||
'domain' => 'mrcasual.com'
|
'domain' => 'mrcasual.com'
|
||||||
);
|
);
|
||||||
$this->from = 'Sender <do-not-reply@mailpoet.com>';
|
$this->from = 'Sender <staff@mailpoet.com>';
|
||||||
$this->mailer = new MailGun($this->settings['domain'], $this->settings['api_key'], $this->from);
|
$this->mailer = new MailGun($this->settings['domain'], $this->settings['api_key'], $this->from);
|
||||||
$this->mailer->subscriber = 'Recipient <mailpoet-phoenix-test@mailinator.com>';
|
$this->mailer->subscriber = 'Recipient <mailpoet-phoenix-test@mailinator.com>';
|
||||||
$this->mailer->newsletter = array(
|
$this->mailer->newsletter = array(
|
||||||
|
@@ -9,7 +9,7 @@ class MandrillCest {
|
|||||||
'type' => 'API',
|
'type' => 'API',
|
||||||
'api_key' => '692ys1B7REEoZN7R-dYwNA'
|
'api_key' => '692ys1B7REEoZN7R-dYwNA'
|
||||||
);
|
);
|
||||||
$this->fromEmail = 'do-not-reply@mailpoet.com';
|
$this->fromEmail = 'staff@mailpoet.com';
|
||||||
$this->fromName = 'Sender';
|
$this->fromName = 'Sender';
|
||||||
$this->mailer = new Mandrill($this->settings['api_key'], $this->fromEmail, $this->fromName);
|
$this->mailer = new Mandrill($this->settings['api_key'], $this->fromEmail, $this->fromName);
|
||||||
$this->mailer->subscriber = 'Recipient <mailpoet-phoenix-test@mailinator.com>';
|
$this->mailer->subscriber = 'Recipient <mailpoet-phoenix-test@mailinator.com>';
|
||||||
@@ -60,6 +60,30 @@ class MandrillCest {
|
|||||||
->equals(json_encode($this->mailer->getBody()));
|
->equals(json_encode($this->mailer->getBody()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function itCanProcessSubscriber() {
|
||||||
|
expect($this->mailer->processSubscriber('test@test.com'))
|
||||||
|
->equals(array(
|
||||||
|
array(
|
||||||
|
'email' => 'test@test.com',
|
||||||
|
'name' => ''
|
||||||
|
)
|
||||||
|
));
|
||||||
|
expect($this->mailer->processSubscriber('First <test@test.com>'))
|
||||||
|
->equals(array(
|
||||||
|
array(
|
||||||
|
'email' => 'test@test.com',
|
||||||
|
'name' => 'First'
|
||||||
|
)
|
||||||
|
));
|
||||||
|
expect($this->mailer->processSubscriber('First Last <test@test.com>'))
|
||||||
|
->equals(array(
|
||||||
|
array(
|
||||||
|
'email' => 'test@test.com',
|
||||||
|
'name' => 'First Last'
|
||||||
|
)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
function itCannotSendWithoutProperAPIKey() {
|
function itCannotSendWithoutProperAPIKey() {
|
||||||
$mailer = clone $this->mailer;
|
$mailer = clone $this->mailer;
|
||||||
$mailer->api_key = 'someapi';
|
$mailer->api_key = 'someapi';
|
||||||
|
@@ -9,7 +9,7 @@ class SendGridCest {
|
|||||||
'type' => 'API',
|
'type' => 'API',
|
||||||
'api_key' => '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'
|
'api_key' => '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'
|
||||||
);
|
);
|
||||||
$this->fromEmail = 'do-not-reply@mailpoet.com';
|
$this->fromEmail = 'staff@mailpoet.com';
|
||||||
$this->fromName = 'Sender';
|
$this->fromName = 'Sender';
|
||||||
$this->mailer = new SendGrid($this->settings['api_key'], $this->fromEmail, $this->fromName);
|
$this->mailer = new SendGrid($this->settings['api_key'], $this->fromEmail, $this->fromName);
|
||||||
$this->mailer->subscriber = 'Recipient <mailpoet-phoenix-test@mailinator.com>';
|
$this->mailer->subscriber = 'Recipient <mailpoet-phoenix-test@mailinator.com>';
|
||||||
|
91
tests/unit/Mailer/SMTP/SMTPCest.php
Normal file
91
tests/unit/Mailer/SMTP/SMTPCest.php
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use MailPoet\Mailer\SMTP\SMTP;
|
||||||
|
|
||||||
|
class SMTPCest {
|
||||||
|
function __construct() {
|
||||||
|
$this->settings = array(
|
||||||
|
'name' => 'SMTP',
|
||||||
|
'type' => 'SMTP',
|
||||||
|
'host' => 'email-smtp.us-west-2.amazonaws.com',
|
||||||
|
'port' => 587,
|
||||||
|
'authentication' => array(
|
||||||
|
'login' => 'AKIAIGPBLH6JWG5VCBQQ',
|
||||||
|
'password' => 'AudVHXHaYkvr54veCzqiqOxDiMMyfQW3/V6F1tYzGXY3'
|
||||||
|
),
|
||||||
|
'encryption' => 'tls'
|
||||||
|
);
|
||||||
|
$this->fromEmail = 'staff@mailpoet.com';
|
||||||
|
$this->fromName = 'Sender';
|
||||||
|
$this->mailer = new SMTP($this->settings['host'], $this->settings['port'], $this->settings['authentication'], $this->settings['encryption'], $this->fromEmail, $this->fromName);
|
||||||
|
$this->subscriber = 'Recipient <mailpoet-phoenix-test@mailinator.com>';
|
||||||
|
$this->newsletter = array(
|
||||||
|
'subject' => 'testing SMTP',
|
||||||
|
'body' => array(
|
||||||
|
'html' => 'HTML body',
|
||||||
|
'text' => 'TEXT body'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function itCanBuildMailer() {
|
||||||
|
$mailer = $this->mailer->buildMailer();
|
||||||
|
expect($mailer->getTransport()
|
||||||
|
->getHost())
|
||||||
|
->equals($this->settings['host']);
|
||||||
|
expect($mailer->getTransport()
|
||||||
|
->getPort())
|
||||||
|
->equals($this->settings['port']);
|
||||||
|
expect($mailer->getTransport()
|
||||||
|
->getUsername())
|
||||||
|
->equals($this->settings['authentication']['login']);
|
||||||
|
expect($mailer->getTransport()
|
||||||
|
->getPassword())
|
||||||
|
->equals($this->settings['authentication']['password']);
|
||||||
|
expect($mailer->getTransport()
|
||||||
|
->getEncryption())
|
||||||
|
->equals($this->settings['encryption']);
|
||||||
|
}
|
||||||
|
|
||||||
|
function itCanCreateMessage() {
|
||||||
|
$message = $this->mailer->createMessage($this->newsletter, $this->subscriber);
|
||||||
|
expect($message->getTo())
|
||||||
|
->equals(array('mailpoet-phoenix-test@mailinator.com' => 'Recipient'));
|
||||||
|
expect($message->getFrom())
|
||||||
|
->equals(array($this->fromEmail => $this->fromName));
|
||||||
|
expect($message->getSubject())
|
||||||
|
->equals($this->newsletter['subject']);
|
||||||
|
expect($message->getBody())
|
||||||
|
->equals($this->newsletter['body']['html']);
|
||||||
|
expect($message->getChildren()[0]->getContentType())
|
||||||
|
->equals('text/plain');
|
||||||
|
}
|
||||||
|
|
||||||
|
function itCanProcessSubscriber() {
|
||||||
|
expect($this->mailer->processSubscriber('test@test.com'))
|
||||||
|
->equals(array('test@test.com' => ''));
|
||||||
|
expect($this->mailer->processSubscriber('First <test@test.com>'))
|
||||||
|
->equals(array('test@test.com' => 'First'));
|
||||||
|
expect($this->mailer->processSubscriber('First Last <test@test.com>'))
|
||||||
|
->equals(array('test@test.com' => 'First Last'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function itCantSentWithoutProperAuthentication() {
|
||||||
|
$mailer = clone $this->mailer;
|
||||||
|
$mailer->smtpAuthentication['login'] = 'someone';
|
||||||
|
$mailer->mailer = $mailer->buildMailer();
|
||||||
|
$result = $mailer->send(
|
||||||
|
$this->newsletter,
|
||||||
|
$this->subscriber
|
||||||
|
);
|
||||||
|
expect($result)->false();
|
||||||
|
}
|
||||||
|
|
||||||
|
function itCanSend() {
|
||||||
|
$result = $this->mailer->send(
|
||||||
|
$this->newsletter,
|
||||||
|
$this->subscriber
|
||||||
|
);
|
||||||
|
expect($result)->true();
|
||||||
|
}
|
||||||
|
}
|
@@ -8,7 +8,7 @@ class MailerCest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function itCanConstruct() {
|
function itCanConstruct() {
|
||||||
expect($this->router->from)->equals('Sender <mailpoet-phoenix-test@mailinator.com>');
|
expect($this->router->from)->equals('Sender <staff@mailpoet.com>');
|
||||||
}
|
}
|
||||||
|
|
||||||
function itCanTransformSubscriber() {
|
function itCanTransformSubscriber() {
|
||||||
|
Reference in New Issue
Block a user