AWS SES sending mail with attachement using Amazon iOS SDK

人走茶凉 提交于 2019-12-11 06:37:45

问题


Does anyone know how to send a mail with an attachment using Amazon SES with the iOS SDK.


回答1:


To send an email with SES using the iOS SDK you need to create a AWSSESSendRawEmailRequest and make sure that the rawMessage (AWSSESRawMessage) data format complies with Internet email standards regarding email header fields, MIME types, MIME encoding, and base64 encoding.

This means converting the NSData of your attachment to a base64 string and inserting it in the raw email string with all the headers etc.

Such a string may look something like this:

        From: "Bob" <bob@example.com>
        To: "Andrew" <andrew@example.com>
        Date: Wed, 2 Mar 2011 11:39:34 -0800
        Subject: Customer service contact info
        Accept-Language: en-US
        Content-Language: en-US
        Content-Type: multipart/mixed;
            boundary="_003_97DCB304C5294779BEBCFC8357FCC4D2"
        MIME-Version: 1.0

        --_003_97DCB304C5294779BEBCFC8357FCC4D2
        Content-Type: text/plain; charset="us-ascii"
        Content-Transfer-Encoding: quoted-printable

        Hi Andrew.  Here are the customer service names and telephone numbers I promised you. 

        See attached.

        -Bob

        --_003_97DCB304C5294779BEBCFC8357FCC4D2
        Content-Type: text/plain; name="cust-serv.txt"
        Content-Description: cust-serv.txt
        Content-Disposition: attachment; filename="cust-serv.txt"; size=1180;
            creation-date="Wed, 02 Mar 2011 11:39:39 GMT";
            modification-date="Wed, 02 Mar 2011 11:39:39 GMT"
        Content-Transfer-Encoding: base64

        TWFyeSBEYXZpcyAtICgzMjEpIDU1NS03NDY1DQpDYXJsIFRob21hcyAtICgzMjEpIDU1NS01MjM1
        DQpTYW0gRmFycmlzIC0gKDMyMSkgNTU1LTIxMzQ=

        --_003_97DCB304C5294779BEBCFC8357FCC4D2

Note that AWSSESRawMessage has a data (NSData) property so this string will need to be converted to NSData before using it in AWSSESRawMessage



来源:https://stackoverflow.com/questions/41095689/aws-ses-sending-mail-with-attachement-using-amazon-ios-sdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!