« Back to Documentation Overview

SendEmail – v1.0

 SendEmail(string apikey, array message, bool track_opens, bool track_clicks, array tags)

Composes an email message based on input data, and then immediately queues the message for sending. We manage requeuing for you, so if a message gets rejected for a queueing issue, you've completely blown out your Amazon sending limits. You are encourage to always make this call with a POST request.
Important: 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.

Section
Sending
AmazonDoc
This is equivalent to Amazon's SendEmail call
Parameters
apikey a valid API Key for your user account. Get by visiting your API dashboard
message the message data with the following keys:
stringhtmlthe full HTML content to be sent
stringtextoptional - the full Text content to be sent
stringsubjectthe message subject
stringfrom_namethe from name to be used
stringfrom_emaila verified email address from ListVerifiedEmailAddresses
arrayreply_tooption the email address(es) that should be set as reply-to email addresses.
arrayto_emailan array containing up to 50 email addresses to receive this email
arrayto_nameoptional - an array of To names to be used. Theses will be processed in order with to_email, so every to_email should have a to_name, even if it is blank.
arraycc_emailoptional - an array containing up to 50 email addresses to receive this email as CC recipients
arraycc_nameoptional - an array of CC names to be used. Theses will be processed in order with to_email, so every to_email should have a to_name, even if it is blank.
arraybcc_emailoptional - an array containing up to 50 email addresses to receive this email as BCC recipients
arraybcc_nameoptional - an array of BCC names to be used. Theses will be processed in order with to_email, so every to_email should have a to_name, even if it is blank.
boolautogen_htmloptional - if an html section is not passed in, generate it from the text. For historical reasons, this defaults to true.
track_opens whether or not to turn on MailChimp-specific opens tracking
track_clicks whether or not to turn on MailChimp-specific click tracking
tags an array of strings to tag the message with. Stats can be accumulated using tags, though we only store the first 100 we see, so this should not be unique or change frequently. Tags should be 50 characters or less - any starting with an underscore are reserved and will cause errors.
Returns
array containing the "status" as either "sent" or "queued" along with extra info on what happened.

Examples (2)

download example code

[1] SendEmail.php

  1. <?php
  2. $apikey = 'MY_API_KEY';
  3.  
  4. $to_emails = array('you@example.com', 'your_mom@example.com');
  5. $to_names = array('You', 'Your Mom');
  6.  
  7. $message = array(
  8. 'html'=>'Yo, this is the <b>html</b> portion',
  9. 'text'=>'Yo, this is the *text* portion',
  10. 'subject'=>'This is the subject',
  11. 'from_name'=>'Me!',
  12. 'from_email'=>'verifed@example.com',
  13. 'to_email'=>$to_emails,
  14. 'to_name'=>$to_names
  15. );
  16.  
  17. $tags = array('WelcomeEmail');
  18.  
  19. $params = array(
  20. 'apikey'=>$apikey,
  21. 'message'=>$message,
  22. 'track_opens'=>true,
  23. 'track_clicks'=>false,
  24. 'tags'=>$tags
  25. );
  26.  
  27. $url = "http://us1.sts.mailchimp.com/1.0/SendEmail";
  28.  
  29. $ch = curl_init();
  30. curl_setopt($ch, CURLOPT_URL, $url.'?'.http_build_query($params));
  31. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  32.  
  33. $result = curl_exec($ch);
  34. echo $result;
  35. curl_close ($ch);
  36.  
  37. $data = json_decode($result);
  38. echo "Status = ".$data->status."\n";
  39.  

[2] SendEmail.sh

  1. #!/bin/sh -e
  2. curl -l http://us1.sts.mailchimp.com/1.0/SendEmail \
  3. -d apikey=MY_API_KEY \
  4. -d message[html]=urlencode_some_html_content
  5. -d message[text]=urlencode_some_html_content
  6. -d message[from_email]=verified@example.com
  7. -d message[from_name]=Me
  8. -d message[to_email][0]=you@example.com
  9. -d message[to_email][1]=yourmom@example.com
  10. -d track_opens=true
  11. -d track_clicks=false
  12. -d tags[0]=WelcomeEmail
  13.