You are here

public function AmazonSesSystem::mail in Amazon SES 7.2

Same name and namespace in other branches
  1. 7 includes/amazon_ses.mail.inc \AmazonSesSystem::mail()

Send an e-mail message, using Drupal variables and default settings.

Overrides DefaultMailSystem::mail

File

includes/amazon_ses.mail.inc, line 24
Amazon SES Mail system Used by drupal core system.

Class

AmazonSesSystem
Create system which will send mail using amazon ses api.

Code

public function mail(array $message) {

  // Remove uneccessary parameters.
  unset($message['headers']);
  unset($message['params']);
  unset($message['key']);
  unset($message['module']);
  unset($message['language']);
  unset($message['id']);
  $reply_to = variable_get('amazon_ses_reply_to', $message['from']);
  $return_path = variable_get('amazon_ses_return_path', $message['from']);
  if (!empty($reply_to)) {
    $message['ReplyToAddresses'] = $reply_to;
  }
  if (!empty($return_path)) {
    $message['ReturnPath'] = $return_path;
  }

  // Convert new line to br for html mail.
  $message['body'] = nl2br($message['body']);
  $action_parameters['mail'] = $message;
  $result = amazon_ses_send_request('SendEmail', $action_parameters);
  if (!empty($result['message_id'])) {
    return TRUE;
  }
  return FALSE;
}