class AmazonSes in Amazon SES 2.0.x
Amazon SES mail system plugin.
Plugin annotation
@Mail(
id = "amazon_ses_mail",
label = @Translation("Amazon SES mailer"),
description = @Translation("Sends an email using Amazon SES.")
)
Hierarchy
- class \Drupal\Core\Mail\Plugin\Mail\PhpMail implements MailInterface
- class \Drupal\amazon_ses\Plugin\Mail\AmazonSes implements MailInterface, ContainerFactoryPluginInterface uses AmazonSesHandlerTrait
Expanded class hierarchy of AmazonSes
File
- src/
Plugin/ Mail/ AmazonSes.php, line 22
Namespace
Drupal\amazon_ses\Plugin\MailView source
class AmazonSes extends PhpMail implements MailInterface, ContainerFactoryPluginInterface {
use AmazonSesHandlerTrait;
/**
* The config object.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $config;
/**
* The queue object.
*
* @var \Drupal\Core\Queue\QueueInterface
*/
protected $queue;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
$instance = new static($container, $configuration, $plugin_id, $plugin_definition);
$instance
->setHandler($container
->get('amazon_ses.handler'))
->setConfig($container
->get('config.factory'))
->setQueue($container
->get('queue'));
return $instance;
}
/**
* Set the config object.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory object.
*
* @return $this
*/
protected function setConfig(ConfigFactoryInterface $config_factory) {
$this->config = $config_factory
->get('amazon_ses.settings');
return $this;
}
/**
* Set the queue object.
*
* @param \Drupal\Core\Queue\QueueFactory $queue_factory
* The queue factory service.
*
* @return $this
*/
protected function setQueue(QueueFactory $queue_factory) {
$this->queue = $queue_factory
->get('amazon_ses_mail_queue');
return $this;
}
/**
* {@inheritdoc}
*/
public function mail(array $message) {
if ($this->config
->get('queue')) {
$result = $this->queue
->createItem($message);
return (bool) $result;
}
else {
$message_id = $this->handler
->send($message);
return (bool) $message_id;
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AmazonSes:: |
protected | property | The config object. | |
AmazonSes:: |
protected | property | The queue object. | |
AmazonSes:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
AmazonSes:: |
public | function |
Sends an email message. Overrides PhpMail:: |
|
AmazonSes:: |
protected | function | Set the config object. | |
AmazonSes:: |
protected | function | Set the queue object. | |
AmazonSesHandlerTrait:: |
protected | property | The Amazon SES handler service. | |
AmazonSesHandlerTrait:: |
protected | function | Set the handler object. | |
PhpMail:: |
protected | property | The configuration factory. | |
PhpMail:: |
public | function |
Concatenates and wraps the email body for plain-text mails. Overrides MailInterface:: |
1 |
PhpMail:: |
private | constant | A list of headers that can contain multiple email addresses. | |
PhpMail:: |
protected static | function | Disallows potentially unsafe shell characters. | |
PhpMail:: |
public | function | PhpMail constructor. |