MandrillTestService.php in Mandrill 8
File
src/MandrillTestService.php
View source
<?php
namespace Drupal\mandrill;
class MandrillTestService extends MandrillService {
protected function handleSendResponse($response, $message) {
if (isset($response['status'])) {
return FALSE;
}
foreach ($response as $result) {
\Drupal::moduleHandler()
->invokeAll('mandrill_mailsend_result', [
$result,
], [
$message,
]);
switch ($result['status']) {
case "error":
case "invalid":
case "rejected":
return FALSE;
}
}
return TRUE;
}
public function send($message) {
if (\Drupal::config('system.mail')
->get('interface.default') === 'test_mail_collector') {
$captured_emails = \Drupal::state()
->get('system.test_mail_collector') ?: [];
$captured_emails[] = $message;
\Drupal::state()
->set('system.test_mail_collector', $captured_emails);
return TRUE;
}
return parent::send($message);
}
}