vi /etc/postfix/main.cf

smtp_sender_dependent_authentication = yes
sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relay
relayhost =[smtpapi.yourdomain.com]:587

vi /etc/postfix/sender_relay
support@yourdomain.com [email-smtp.us-west-2.amazonaws.com]:587
user@yourdomain.com [email-smtp.us-east-1.amazonaws.com]:587


vi /etc/postfix/sasl_passwd
[smtpapi.sengridyourdomain.com]:587 usernameXXXXXXXX:passwordXXXXXXXXXXXXXXXXXXXXXXXXXXXX

[email-smtp.us-east-1.amazonaws.com]:587 usernameXXXXXXXX:passwordXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[email-smtp.us-west-2.amazonaws.com]:587 usernameXXXXXXXX:passwordXXXXXXXXXXXXXXXXXXXXXXXXXXXX


postmap /etc/postfix/sender_relay

postmap /etc/postfix/sasl_passwd

/etc/init.d/postfix restart



As per above setup support email sent through SES west2 and specific user email id sent through SES east-1 rest all email sent through sendgrid API

email test via console & after deliver check show original of email

echo "body of email" | mail -s "subject of the email" -r sender@yourdomain.com recipeient@anotherdomain.com

echo "body of email" | mail -s "subject of the email" -r support@yourdomain.com recipeient@personalemailid

 echo "body of email" | mail -s "subject of the email" -r user@yourdomain.com recipeient@personalemailid

echo "body of email" | mail -s "subject of the email" -r anyoheremail@yourdomain.com recipeient@personalemailid

0 comments:

Post a Comment