Catches exceptions during sending
This commit is contained in:
@@ -50,10 +50,14 @@ class AmazonSES {
|
||||
}
|
||||
|
||||
function send($newsletter, $subscriber, $extra_params = array()) {
|
||||
$result = wp_remote_post(
|
||||
$this->url,
|
||||
$this->request($newsletter, $subscriber, $extra_params)
|
||||
);
|
||||
try {
|
||||
$result = wp_remote_post(
|
||||
$this->url,
|
||||
$this->request($newsletter, $subscriber, $extra_params)
|
||||
);
|
||||
} catch(\Exception $e) {
|
||||
return Mailer::formatMailerSendErrorResult($e->getMessage());
|
||||
}
|
||||
if(is_wp_error($result)) {
|
||||
return Mailer::formatMailerConnectionErrorResult($result->get_error_message());
|
||||
}
|
||||
|
@@ -216,6 +216,16 @@ class AmazonSESTest extends \MailPoetTest {
|
||||
expect($result['response'])->false();
|
||||
}
|
||||
|
||||
function testItCatchesSendingErrors() {
|
||||
$invalid_subscriber = 'john.@doe.com';
|
||||
$result = $this->mailer->send(
|
||||
$this->newsletter,
|
||||
$invalid_subscriber
|
||||
);
|
||||
expect($result['response'])->false();
|
||||
expect($result['error_message'])->contains('does not comply with RFC 2822');
|
||||
}
|
||||
|
||||
function testItCanSend() {
|
||||
if(getenv('WP_TEST_MAILER_ENABLE_SENDING') !== 'true') return;
|
||||
$result = $this->mailer->send(
|
||||
|
Reference in New Issue
Block a user