send_raw_email ( $raw_message, $opt )

Sends an email message, with header and content specified by the client. The SendRawEmail action is useful for sending multipart MIME emails. The raw text of the message must comply with Internet email standards; otherwise, the message cannot be sent.

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. This includes any attachments that are part of the message.

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

public

Parameters

Parameter

Type

Required

Description

$raw_message

array

Required

The raw text of the message. The client is responsible for ensuring the following:

  • Message must contain a header and a body, separated by a blank line.
  • All required header fields must be present.
  • Each part of a multipart MIME message must be formatted properly.
  • MIME content types must be among those supported by Amazon SES. Refer to the Amazon SES Developer Guide for more details.
  • Content must be base64-encoded, if MIME requires it.
  • x - array - Optional - This represents a simple array index.
    • Data - blob - Required - The raw data of the message. The client must ensure that the message format complies with Internet email standards regarding email header fields, MIME types, MIME encoding, and base64 encoding (if necessary). For more information, go to the Amazon SES Developer Guide.

$opt

array

Optional

An associative array of parameters that can have the following keys:

  • Source - string - Optional - The identity’s email address.

    If you specify the Source parameter, then bounce notifications and complaints will be sent to this email address. This takes precedence over any Return-Path header that you might include in the raw text of the message.

  • Destinations - string|array - Optional - A list of destinations for the message. Pass a string for a single value, or an indexed array for multiple values.
  • 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

Type

Description

CFResponse

A CFResponse object containing a parsed HTTP response.

Examples

Send raw email

// Store raw email content
    $raw_email = <<<HTML
Subject: Amazon SES Test
MIME-Version: 1.0
Content-type: Multipart/Mixed; boundary="NextPart"

--NextPart
Content-Type: text/plain;

This is the message body.

--NextPart
Content-Type: text/plain;
Content-Disposition: attachment;
filename="test.txt"

This is the text in the attachment.

--NextPart--
HTML;

    // Instantiate the class
    $email = new AmazonSES();

    $response = $email->send_raw_email(array(
        'Data' => base64_encode($raw_email),
    ), array(
        'Source' => 'no-reply@amazon.com',
        'Destinations' => array(
            'nobody@amazon.com',
        ),
    ));

    // Success?
    var_dump($response->isOK());
Result:
bool(true)

Related Methods

Source

Method defined in services/ses.class.php | Toggle source view (20 lines) | View on GitHub

public function send_raw_email($raw_message, $opt = null)
{
    if (!$opt) $opt = array();
            
    // Required map (non-list)
    $opt = array_merge($opt, CFComplexType::map(array(
        'RawMessage' => (is_array($raw_message) ? $raw_message : array($raw_message))
    ), 'member'));

    // Optional list (non-map)
    if (isset($opt['Destinations']))
    {
        $opt = array_merge($opt, CFComplexType::map(array(
            'Destinations' => (is_array($opt['Destinations']) ? $opt['Destinations'] : array($opt['Destinations']))
        ), 'member'));
        unset($opt['Destinations']);
    }

    return $this->authenticate('SendRawEmail', $opt);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback