7

我们正在使用 AWS SES 从我们的 C# 应用程序发送电子邮件。我们有一个大小为 9.28MB 的附件(PDF 文件),当我们尝试发送带有附件的电子邮件时,它会引发以下异常:

System.Xml.XmlException: Root element is missing. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.ParseDocumentContent() at Amazon.Runtime.Internal.Transform.UnmarshallerContext.Read() at Amazon.Runtime.Internal.Transform.ErrorResponseUnmarshaller.Unmarshall(UnmarshallerContext context) at Amazon.SimpleEmail.Model.Transform.SendRawEmailResponseUnmarshaller.UnmarshallException(UnmarshallerContext context, Exception innerException, HttpStatusCode statusCode) at Amazon.Runtime.AmazonWebServiceClient.processWebException[X,Y](String requestName, WebException we, HttpWebRequest webRequest, IResponseUnmarshaller`2 unmarshaller, IRequest`1 request, Int32 retries) at Amazon.Runtime.AmazonWebServiceClient.Invoke[X,Y](IRequest`1 request, AbstractAWSSigner signer, IResponseUnmarshaller`2 unmarshaller) at Amazon.SimpleEmail.AmazonSimpleEmailServiceClient.SendRawEmail(SendRawEmailRequest sendRawEmailRequest) at MyApp.AmazonSESWrapper.SendRawEmail(String awsAccessKey, String awsSecretKey, List`1 to, List`1 cc, List`1 bcc, String senderEmailAddress, String replyToEmailAddress, String subject, String body, String text, String filePath, String exceptionDetails)

但是当我们发送一个 7.50MB 的 word 文档作为附件时,我们得到了以下异常:

Amazon.SimpleEmail.AmazonSimpleEmailServiceException: Message length is more than 10485760 bytes long: '10788624'. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request. at System.Net.HttpWebRequest.GetResponse() at Amazon.Runtime.AmazonWebServiceClient.Invoke[X,Y](IRequest`1 request, AbstractAWSSigner signer, IResponseUnmarshaller`2 unmarshaller) --- End of inner exception stack trace --- at Amazon.Runtime.AmazonWebServiceClient.processWebException[X,Y](String requestName, WebException we, HttpWebRequest webRequest, IResponseUnmarshaller`2 unmarshaller, IRequest`1 request, Int32 retries) at Amazon.Runtime.AmazonWebServiceClient.Invoke[X,Y](IRequest`1 request, AbstractAWSSigner signer, IResponseUnmarshaller`2 unmarshaller) at Amazon.SimpleEmail.AmazonSimpleEmailServiceClient.SendRawEmail(SendRawEmailRequest sendRawEmailRequest) at 

从论坛和常见问题解答中,它说最大附件大小为 10MB,但小于 10MB 的附件也会出现错误。

https://forums.aws.amazon.com/thread.jspa?messageID=346305

http://aws.amazon.com/ses/faqs/#49

请就此提出建议。

4

1 回答 1

8

还有整体消息大小限制,也是 10M。根据http://aws.amazon.com/ses/faqs/

Amazon SES 将接受大小不超过 10 MB 的电子邮件。这包括作为邮件一部分的任何附件。

因此,您必须确保您的请求符合这些限制。

(我个人认为这是一个错误,即 Amazon API 抛出“XmlException:缺少根元素。”以防消息大小大大超过限制。这完全是误导。)

于 2014-05-26T12:06:06.940 回答