I have a setup with CiviCRM and Amazon SES, everything is working fine.
A Problem arises with the bounce handling. Amazon can either do that internally via Amazon SNS, or just forward the mails to your domain for common handling (Catchall or VERP).
I wanted to use the SNS mechanism, and amazon sends the mail correctly to the specified address, but the email isn't a typical bounce mail, but instead the original headers are JSON encoded like this:
{ "notificationType": "Bounce", "bounce": {
"bounceType": "Permanent",
"bounceSubType": "General",
"bouncedRecipients": [{
"emailAddress": "[email protected]",
"action": "failed",
"status": "5.1.1",
"diagnosticCode": "smtp; 550 5.1.1 user unknown"
}],
"timestamp": "2017-11-20T11:05:06.477Z",
"feedbackId": "0102015fd91a6479-ae22395c-1f7d-4423-a9e5-e0715bffc731-000000",
"remoteMtaIp": "1.2.3.4",
"reportingMTA": "dsn; a4-8.smtp-out.eu-west-1.amazonses.com" }, "mail": {
"timestamp": "2017-11-20T11:05:04.000Z",
"source": "[email protected]",
"sourceArn": "ARN_INTERNAL:identity/example.com",
"sourceIp": "1.2.3.4",
"sendingAccountId": "__ID__",
"messageId": "0102015fd91a5ca3-93c245fe-e333-46ae-8fed-96160d20cfab-000000",
"destination": ["[email protected]"],
"headersTruncated": false,
"headers": [{
"name": "Received",
"value": "from crm.example.com (mx02.example.com [1.2.3.4]) by email-smtp.amazonaws.com with SMTP (SimpleEmailService-2638500019) id MbY8b9mKuaex7LdPcwd8 for [email protected]; Mon, 20 Nov 2017 11:05:04 +0000 (UTC)"
}, {
"name": "MIME-Version",
"value": "1.0"
}, {
"name": "Content-Type",
"value": "multipart/alternative; boundary=\"=_99c8dccfc484a99b0f6101141a34c4ae\""
}, {
"name": "Reply-To",
"value": "\"Example Company\" <[email protected]>"
}, {
"name": "Return-Path",
"value": "[email protected]"
}, {
"name": "From",
"value": "\"Example Company\" <[email protected]>"
}, {
"name": "Subject",
"value": "Bounce Test – Monday 4"
}, {
"name": "List-Unsubscribe",
"value": "<mailto:[email protected]>"
}, {
"name": "job_id",
"value": "83"
}, {
"name": "To",
"value": "Tom TestUser <[email protected]>"
}, {
"name": "Precedence",
"value": "bulk"
}, {
"name": "X-CiviMail-Bounce",
"value": "[email protected]"
}, {
"name": "Date",
"value": "Mon, 20 Nov 2017 12:05:04 +0100"
}],
"commonHeaders": {
"returnPath": "[email protected]",
"from": ["Example Company <[email protected]>"],
"replyTo": ["Example Company <[email protected]>"],
"date": "Mon, 20 Nov 2017 12:05:04 +0100",
"to": ["Tom TestUser <[email protected]>"],
"subject": "Bounce Test – Monday 4"
} } }
Civi cannot handle this type of message (to the best of my knowledge) and it is then moved to the ignored folder. I'm pretty sure I am not the first one to have this problem, but I couldn't find any solutions to this. Maybe someone has written a parser for those type of messages already?
Help/Suggestions are welcome!