问题
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