Hello,

I use Debian 9 on AWS EC2. If mail is sent directly from EC2 host then
some mail service provider such as Gmail rejects receiving it. So I set up
so that mail is sent through AWS SES with following steps.

1. Obtain SES SMTP credential accoring to following document
   https://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-credentials.html
2. Verify domain with SES accoring to following document
   
https://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-domain-procedure.html
3. Move the domain out of SES sandbox accoring to following document
   
https://docs.aws.amazon.com/ses/latest/DeveloperGuide/request-production-access.html
4. Set up postfix to following document
   https://docs.aws.amazon.com/ses/latest/DeveloperGuide/postfix.html

And postfix is configured so that 'postconf -n' shows as following.

----------------------------------------------------------------------
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = yes
biff = no
compatibility_level = 2
home_mailbox = Maildir/
inet_interfaces = all
inet_protocols = all
mailbox_size_limit = 0
milter_default_action = accept
mydestination = $myhostname, $mydomain, localhost.$mydomain, localhost
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost = email-smtp.us-east-1.amazonaws.com:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtp_tls_ciphers = high
smtp_tls_loglevel = 1
smtp_tls_mandatory_ciphers = high
smtp_tls_mandatory_protocols = !SSLv2 !SSLv3 !TLSv1 !TLSv1.1
smtp_tls_note_starttls_offer = yes
smtp_tls_protocols = !SSLv2 !SSLv3 !TLSv1 !TLSv1.1
smtp_tls_security_level = encrypt
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
smtpd_milters = inet:localhost:11332
smtpd_recipient_restrictions = permit_mynetworks reject_unauth_destination 
check_policy_service inet:127.0.0.1:10023
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated 
defer_unauth_destination
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noplaintext,noanonymous
smtpd_sasl_tls_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtpd_tls_cert_file = /etc/letsencrypt/live/examle.org/fullchain.pem
smtpd_tls_ciphers = high
smtpd_tls_key_file = /etc/letsencrypt/live/examle.org/privkey.pem
smtpd_tls_loglevel = 1
smtpd_tls_mandatory_ciphers = high
smtpd_tls_mandatory_protocols = !SSLv2 !SSLv3 !TLSv1 !TLSv1.1
smtpd_tls_protocols = !SSLv2 !SSLv3 !TLSv1 !TLSv1.1
smtpd_tls_security_level = may
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
----------------------------------------------------------------------

And with this settings I confirmed that mail is successfully delivered
from the EC2 host to destination that mail is rejected if delivered
directly.

But if I try to forward mail sent from outside to this host by using
~/.forward or something else, then SES rejects such mail with
following log messages.

----------------------------------------------------------------------
Jan 19 14:53:32 server postfix/smtpd[19403]: connect from 
gate.example.com[10.0.0.1]
Jan 19 14:53:32 server postfix/smtpd[19403]: Anonymous TLS connection 
established from gate.example.com[10.0.0.1]: TLSv1.2 with cipher 
ADH-AES256-GCM-SHA384 (256/256 bits)
Jan 19 14:53:32 server postfix/smtpd[19403]: 629A74F3: 
client=gate.example.com[10.0.0.1]
Jan 19 14:53:32 server postfix/cleanup[19410]: 629A74F3: 
message-id=<[email protected]>
Jan 19 14:53:36 server postfix/qmgr[16757]: 629A74F3: from=<[email protected]>, 
size=1495, nrcpt=1 (queue active)
Jan 19 14:53:36 server postfix/smtpd[19403]: disconnect from 
gate.example.com[10.0.0.1] ehlo=2 starttls=1 mail=1 rcpt=1 data=1 quit=1 
commands=7
Jan 19 14:53:36 server postfix/local[19411]: 629A74F3: to=<[email protected]>, 
relay=local, delay=4.1, delays=4.1/0.01/0/0, dsn=2.0.0, status=sent (delivered 
to maildir)
Jan 19 14:53:36 server postfix/cleanup[19410]: 7FF264F4: 
message-id=<[email protected]>
Jan 19 14:53:36 server postfix/qmgr[16757]: 7FF264F4: from=<[email protected]>, 
size=2199, nrcpt=2 (queue active)
Jan 19 14:53:36 server postfix/local[19411]: 629A74F3: to=<[email protected]>, 
relay=local, delay=4.1, delays=4.1/0.01/0/0.01, dsn=2.0.0, status=sent 
(forwarded as 7FF264F4)
Jan 19 14:53:36 server postfix/qmgr[16757]: 629A74F3: removed
Jan 19 14:53:38 server postfix/smtp[19412]: Trusted TLS connection established 
to email-smtp.us-east-1.amazonaws.com[23.23.175.128]:587: TLSv1.2 with cipher 
ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)
Jan 19 14:53:39 server postfix/smtp[19412]: 7FF264F4: to=<[email protected]>, 
orig_to=<[email protected]>, 
relay=email-smtp.us-east-1.amazonaws.com[23.23.175.128]:587, delay=2.7, 
delays=0.01/0.02/1.8/0.85, dsn=5.0.0, status=bounced (host 
email-smtp.us-east-1.amazonaws.com[23.23.175.128] said: 554 Message rejected: 
Email address is not verified. The following identities failed the check in 
region US-EAST-1: [email protected], example.com mail user <[email protected]> 
(in reply to end of DATA command))
Jan 19 14:53:39 server postfix/cleanup[19410]: 5C8474F5: 
message-id=<[email protected]>
Jan 19 14:53:39 server postfix/qmgr[16757]: 5C8474F5: from=<>, size=5389, 
nrcpt=1 (queue active)
Jan 19 14:53:39 server postfix/bounce[19413]: 7FF264F4: sender non-delivery 
notification: 5C8474F5
Jan 19 14:53:39 server postfix/qmgr[16757]: 7FF264F4: removed
Jan 19 14:53:40 server postfix/smtp[19412]: Trusted TLS connection established 
to email-smtp.us-east-1.amazonaws.com[54.225.136.195]:587: TLSv1.2 with cipher 
ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)
Jan 19 14:53:41 server postfix/smtp[19412]: 5C8474F5: to=<[email protected]>, 
relay=email-smtp.us-east-1.amazonaws.com[54.225.136.195]:587, delay=1.7, 
delays=0/0/1.5/0.16, dsn=5.0.0, status=bounced (host 
email-smtp.us-east-1.amazonaws.com[54.225.136.195] said: 501 Invalid MAIL FROM 
address provided (in reply to MAIL FROM command))
Jan 19 14:53:41 server postfix/qmgr[16757]: 5C8474F5: removed
----------------------------------------------------------------------

Then how should I configure postfix to forward mail from outside
through SES? Please let me know if someone succeeds it.

Best Regards.

---
Yasuhiro KIMURA

Reply via email to