send_email ( $source, $destination, $message, $opt )
Composes an email message based on input data, and then immediately queues the message for
sending.
If you have not yet requested production access to Amazon SES, then you will only be able to
send email to and from verified email addresses and domains. For more information, go to the
Amazon SES Developer
Guide.
The total size of the message cannot exceed 10 MB.
Amazon SES has a limit on the total number of recipients per message: The combined number of
To:, CC: and BCC: email addresses cannot exceed 50. If you need to send an email message to a
larger audience, you can divide your recipient list into groups of 50 or fewer, and then call
Amazon SES repeatedly to send the message to each group.
For every message that you send, the total number of recipients (To:, CC: and BCC:) is counted
against your sending quota - the maximum number of emails you can send in a 24-hour
period. For information about your sending quota, go to the “Managing Your Sending Activity”
section of the Amazon SES
Developer Guide.
Access
Parameters
Parameter |
Type |
Required |
Description |
$source
|
string
|
Required
|
The identity’s email address. |
$destination
|
array
|
Required
|
The destination for this email, composed of To:, CC:, and BCC: fields.
x - array - Optional - This represents a simple array index. ToAddresses - string|array - Optional - The To: field(s) of the message. Pass a string for a single value, or an indexed array for multiple values.CcAddresses - string|array - Optional - The CC: field(s) of the message. Pass a string for a single value, or an indexed array for multiple values.BccAddresses - string|array - Optional - The BCC: field(s) of the message. Pass a string for a single value, or an indexed array for multiple values.
|
$message
|
array
|
Required
|
The message to be sent.
x - array - Optional - This represents a simple array index. Subject - array - Required - The subject of the message: A short summary of the content, which will appear in the recipient’s inbox. x - array - Optional - This represents a simple array index. Data - string - Required - The textual data of the content.Charset - string - Optional - The character set of the content.
Body - array - Required - The message body. x - array - Optional - This represents a simple array index. Text - array - Optional - The content of the message, in text format. Use this for text-based email clients, or clients on high-latency networks (such as mobile devices). x - array - Optional - This represents a simple array index. Data - string - Required - The textual data of the content.Charset - string - Optional - The character set of the content.
Html - array - Optional - The content of the message, in HTML format. Use this for email clients that can process HTML. You can include clickable links, formatted text, and much more in an HTML message. x - array - Optional - This represents a simple array index. Data - string - Required - The textual data of the content.Charset - string - Optional - The character set of the content.
|
$opt
|
array
|
Optional
|
An associative array of parameters that can have the following keys:
ReplyToAddresses - string|array - Optional - The reply-to email address(es) for the message. If the recipient replies to the message, each reply-to address will receive the reply. Pass a string for a single value, or an indexed array for multiple values.ReturnPath - string - Optional - The email address to which bounce notifications are to be forwarded. If the message cannot be delivered to the recipient, then an error message will be returned from the recipient’s ISP; this message will then be forwarded to the email address specified by the ReturnPath parameter.curlopts - array - Optional - A set of values to pass directly into curl_setopt() , where the key is a pre-defined CURLOPT_* constant.returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests. |
Returns
Examples
Send a simple plain-text email (US-ASCII).
// Instantiate the class
$email = new AmazonSES();
$response = $email->send_email(
'no-reply@amazon.com', // Source (aka From)
array('ToAddresses' => array( // Destination (aka To)
'nobody@amazon.com'
)),
array( // Message (short form)
'Subject.Data' => 'Email Test ' . time(),
'Body.Text.Data' => 'This is a simple test message ' . time()
)
);
// Success?
var_dump($response->isOK());
Result:
bool(true)
Send a simple plain-text email (longer form).
Depending on how complex your mail settings are, it may be easier to use the shorter form (above) or the longer form (below).
// Instantiate the class
$email = new AmazonSES();
$response = $email->send_email(
'no-reply@amazon.com', // Source (aka From)
array( // Destination (aka To)
'ToAddresses' => array(
'nobody@amazon.com',
'nobody@amazon.com'
),
'CcAddresses' => 'nobody@amazon.com',
'BccAddresses' => 'no-reply@amazon.com'
),
array( // Message (long form)
'Subject' => array(
'Data' => 'émåîl tést ' . time(),
'Charset' => 'UTF-8'
),
'Body' => array(
'Text' => array(
'Data' => 'Thîs îs å plåîn téxt, ünîcødé tést méssåge ' . time(),
'Charset' => 'UTF-8'
),
'Html' => array(
'Data' => '<p><strong>Thîs îs ån HTML, ünîcødé tést méssåge ' . time() . '</strong></p>',
'Charset' => 'UTF-8'
)
)
),
array( // Optional parameters
'ReplyToAddresses' => array('no-reply@amazon.com', 'nobody@amazon.com')
)
);
// Success?
var_dump($response->isOK());
Result:
bool(true)
Related Methods
Source
Method defined in services/ses.class.php | Toggle source view (26 lines) | View on GitHub
public function send_email($source, $destination, $message, $opt = null)
{
if (!$opt) $opt = array();
$opt['Source'] = $source;
// Required map (non-list)
$opt = array_merge($opt, CFComplexType::map(array(
'Destination' => (is_array($destination) ? $destination : array($destination))
), 'member'));
// Required map (non-list)
$opt = array_merge($opt, CFComplexType::map(array(
'Message' => (is_array($message) ? $message : array($message))
), 'member'));
// Optional list (non-map)
if (isset($opt['ReplyToAddresses']))
{
$opt = array_merge($opt, CFComplexType::map(array(
'ReplyToAddresses' => (is_array($opt['ReplyToAddresses']) ? $opt['ReplyToAddresses'] : array($opt['ReplyToAddresses']))
), 'member'));
unset($opt['ReplyToAddresses']);
}
return $this->authenticate('SendEmail', $opt);
}