You are here

private function AmazonSes::sendEmail in Amazon SES 7.2

Call Query API action SendEmail.

Composes an email message based on input data, and then immediately queues the message for sending.

1 call to AmazonSes::sendEmail()
AmazonSes::performServiceAction in src/AmazonSes.php
Add required parameter & header to the Query according to Query action.

File

src/AmazonSes.php, line 305
Class for interacting with Amazon SES service.

Class

AmazonSes
Modify the drupal mail system to use Amazon SES.

Namespace

Drupal\amazon_ses

Code

private function sendEmail($action_parameter) {
  $result['error'] = FALSE;
  try {
    $message = $action_parameter['mail'];
    dpm($message);
    $response = $this->sesClient
      ->sendEmail([
      'Destination' => [
        'ToAddresses' => [
          $message['to'],
        ],
      ],
      'Message' => [
        'Body' => [
          'Html' => [
            'Data' => $message['body'],
          ],
        ],
        'Subject' => [
          'Data' => $message['subject'],
        ],
      ],
      'ReplyToAddresses' => [
        $message['ReplyToAddresses'],
      ],
      'ReturnPath' => $message['ReturnPath'],
      'Source' => $message['from'],
    ]);
    if (!empty($response['MessageId'])) {
      $result['message_id'] = $response['MessageId'];
    }
  } catch (\Aws\Ses\Exception\SesException $e) {
    $result['message'] = $e
      ->getAwsErrorType();
    $result['errorCode'] = $e
      ->getAwsErrorCode();
    $result['error'] = TRUE;
  }
  return $result;
}