How to get bounce mail using AWS SES using Postfix

I configured postfix to relay mail to Amazon SAS, following their integration guide, and sending email works without problems.

However, I recently wrote a PHP application using the framework that created the wrong email message.

SES rejects the email with "Transaction Error 554: Expected MIME Type Received =", which is acceptable.

However, my local postfix server then tries to send a sender non-delivery notification with the address from = <>, which gets to the relay address.

SES rejects the message "501 Invalid MAIL FROM address (in response to the MAIL FROM command)), and the postfix removes the failure message from the queue.

The question is, what is an easier way to ensure that I get the original 554 error message sent to me? I don’t see a way for the SES relay to accept empty fields, so I believe that the solution will be to configure the postfix to deliver the bounce message directly to me.

Note. I use the term "mail bounce", possibly incorrectly. The letter may have been rejected, but I am not sure of the correct nomenclature of this scenario. The key point is that the message is not received by the SES relay, so it did not actually go out of the door, so to speak.

Jun 12 03:11:21 myserver postfix / smtp [6353]: 411BA21795: to = < valid@validdomain.com >, relay = email-smtp.us-east-1.amazonaws.com [54.243.192.132]: 25, delay = 0.29, delays = 0.05 / 0.02 / 0.15 / 0.07, dsn = 5.0.0, status = bounced (host email-smtp.us-east-1.amazonaws.com [54.243 .192.132] said: 554 Transaction failed: Expected MIME type, got = (in reply to end of DATA command))
Jun 12 03:11:21 myserver postfix / cleanup [6351]: 93F202179B: message-id =
Jun 12 03:11:21 myserver postfix / qmgr [895]: 93F202179B: from = <>, size = 4673, nrcpt = 1 (queue active)
Jun 12 03:11:21 myserver postfix / bounce [6354]: 411BA21795: sender non-delivery notification: 93F202179B
Jun 12 03:11:21 myserver postfix / qmgr [895]: 411BA21795: removed

Jun 12 03:11:21 myserver postfix / smtp [6353]: 93F202179B: to = < valid@validdomain.com >, relay = email-smtp.us-east-1.amazona ws.com [23.21.161.144]: 25 , delay = 0.17, delays = 0.01 / 0 / 0.15 / 0, dsn = 5.0.0, status = bounced (host email-smtp.us-east-1.amazonaws.com [23. 21.161.144] said: 501 Invalid MAIL FROM address provided (in reply to MAIL FROM command))
Jun 12 03:11:21 myserver postfix / qmgr [895]: 93F202179B: removed
+4
source share
2 answers

To receive a related message, you must set the address of the sender of the envelope, which is delivered locally in your postfix installation.

Check out

   postconf mydestination

, . , . - root@name.of.your.machine

0

Postfix, , , (/etc/postfix/main.cf Ubuntu):

# The list of error classes that are reported
notify_classes = bounce, delay, policy, protocol, resource, software

# The recipient of postmaster bounce notifications
bounce_notice_recipient = bounceuser

# The recipient of postmaster notifications about mail delivery problems that
# are caused by policy, resource, software or protocol errors.
error_notice_recipient = bounceuser

# The recipient of postmaster notifications with the message headers of mail
# that cannot be delivered within $delay_warning_time time units
delay_notice_recipient = bounceuser

bounceuser - , , . , /etc/aliases, :

# /dev/null will just delete the message from local
bounceuser: /dev/null, <YOUR_EMAIL_ADDRESS_HERE>

postfix:

sudo newaliases
sudo service postfix restart

^ _ ^

0

Source: https://habr.com/ru/post/1544290/


All Articles