Looking for an Amazon SES example sending a raw mail including attachment

Question:

The Amazon SES documentation is not clear for me. So if you can help me with an example tot send raw text e-mails including a PDF attachment, this will help me a lot. I use Python 2.5 and Google App engine.
I have to use “raw”, because that is the only SES option if I include attachments.

My problems at the moment :

  • What is the content of the post request.
  • Which message fields should I put in the header.
  • How to handle the “returnPath”.
  • How to handle the text body. It should be : Content-Type: text/plain; charset=UTF-8; format=flowed; delsp=yes.
    Content-Transfer-Encoding: base64
  • How do I construct the HMAC signature for this post. I know how to make the signature, but how does the raw string looks for the signature function.

Answer:

Example code here to send SES raw e-mail using a multipart body (plain / html / attachment) :

Example usage:

Leave a Reply