我正在开发基于AWS SES的电子邮件系统发布.对于所有传入的电子邮件,我设置路由以将消息保存在S3存储桶中,以便我可以异步处理它们.我遇到的问题是消息以原始格式保存在S3存储桶中:标题,电子邮件正文等+加密附件(一个巨大的字符串) - 全部在一个文件中.
有没有办法将电子邮件消息从附件中分离出来并将它们保存在AWS SES级别的单独文件中?我正在尝试直接从AWS获取我需要的格式的数据,并避免在流程中添加另一个处理步骤.
如果AWS SES不提供此类功能,那么处理这些消息以获得上述结果的正确方法是什么?
让SES自动为您分割电子邮件似乎不可能.根据此处的文档:
Amazon SES为您提供未经修改的原始电子邮件,通常采用多用途Internet邮件扩展(MIME)格式.
当SES将新的电子邮件文件发送到S3时,我会使用S3或SNS来触发Lambda函数.Lambda函数可以根据需要拆分文件,然后将这些新文件写入另一个S3存储桶.
对于稍后回到此问题的任何人,这是从SES调用Lambda函数时获得的JSON结构的链接.
http://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-notifications-examples.html
它需要一些搜索才能到达那个页面;-)
从链接中,Lambda通知看起来像这样,
{ "notificationType": "Received", "receipt": { "timestamp": "2015-09-11T20:32:33.936Z", "processingTimeMillis": 406, "recipients": [ "recipient@example.com" ], "spamVerdict": { "status": "PASS" }, "virusVerdict": { "status": "PASS" }, "spfVerdict": { "status": "PASS" }, "dkimVerdict": { "status": "PASS" }, "action": { "type": "S3", "topicArn": "arn:aws:sns:us-east-1:012345678912:example-topic", "bucketName": "my-S3-bucket", "objectKey": "\email" } }, "mail": { "timestamp": "2015-09-11T20:32:33.936Z", "source": "0000014fbe1c09cf-7cb9f704-7531-4e53-89a1-5fa9744f5eb6-000000@amazonses.com", "messageId": "d6iitobk75ur44p8kdnnp7g2n800", "destination": [ "recipient@example.com" ], "headersTruncated": false, "headers": [ { "name": "Return-Path", "value": "<0000014fbe1c09cf-7cb9f704-7531-4e53-89a1-5fa9744f5eb6-000000@amazonses.com>" }, { "name": "Received", "value": "from a9-183.smtp-out.amazonses.com (a9-183.smtp-out.amazonses.com [54.240.9.183]) by inbound-smtp.us-east-1.amazonaws.com with SMTP id d6iitobk75ur44p8kdnnp7g2n800 for recipient@example.com; Fri, 11 Sep 2015 20:32:33 +0000 (UTC)" }, { "name": "DKIM-Signature", "value": "v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug; d=amazonses.com; t=1442003552; h=From:To:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Date:Message-ID:Feedback-ID; bh=DWr3IOmYWoXCA9ARqGC/UaODfghffiwFNRIb2Mckyt4=; b=p4ukUDSFqhqiub+zPR0DW1kp7oJZakrzupr6LBe6sUuvqpBkig56UzUwc29rFbJF hlX3Ov7DeYVNoN38stqwsF8ivcajXpQsXRC1cW9z8x875J041rClAjV7EGbLmudVpPX 4hHst1XPyX5wmgdHIhmUuh8oZKpVqGi6bHGzzf7g=" }, { "name": "From", "value": "sender@example.com" }, { "name": "To", "value": "recipient@example.com" }, { "name": "Subject", "value": "Example subject" }, { "name": "MIME-Version", "value": "1.0" }, { "name": "Content-Type", "value": "text/plain; charset=UTF-8" }, { "name": "Content-Transfer-Encoding", "value": "7bit" }, { "name": "Date", "value": "Fri, 11 Sep 2015 20:32:32 +0000" }, { "name": "Message-ID", "value": "<61967230-7A45-4A9D-BEC9-87CBCF2211C9@example.com>" }, { "name": "X-SES-Outgoing", "value": "2015.09.11-54.240.9.183" }, { "name": "Feedback-ID", "value": "1.us-east-1.Krv2FKpFdWV+KUYw3Qd6wcpPJ4Sv/pOPpEPSHn2u2o4=:AmazonSES" } ], "commonHeaders": { "returnPath": "0000014fbe1c09cf-7cb9f704-7531-4e53-89a1-5fa9744f5eb6-000000@amazonses.com", "from": [ "sender@example.com" ], "date": "Fri, 11 Sep 2015 20:32:32 +0000", "to": [ "recipient@example.com" ], "messageId": "<61967230-7A45-4A9D-BEC9-87CBCF2211C9@example.com>", "subject": "Example subject" } } }