Scenario: We received the AWS credentials but were not able to decide what was the quickest way to test if the mail service was working correctly.
Few minutes on google and there was a python script which we modified to our test case. All your need to do is key in your AWScredentials.
What is the good thing about this script? The script writes a detailed log so for example in our case the program was accidentally changed and the from email address was changed. Even though we had Production access enabled we were not able to send emails at all.
I am attaching the script output for quick reference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python emailscripttest.py S | |
['S'] | |
send: 'ehlo ip-172-31-5-44.ap-southeast-1.compute.internal\r\n' | |
reply: '250-email-smtp.amazonaws.com\r\n' | |
reply: '250-8BITMIME\r\n' | |
reply: '250-SIZE 10485760\r\n' | |
reply: '250-STARTTLS\r\n' | |
reply: '250-AUTH PLAIN LOGIN\r\n' | |
reply: '250 Ok\r\n' | |
reply: retcode (250); Msg: email-smtp.amazonaws.com | |
8BITMIME | |
SIZE 10485760 | |
STARTTLS | |
AUTH PLAIN LOGIN | |
Ok | |
send: 'STARTTLS\r\n' | |
reply: '220 Ready to start TLS\r\n' | |
reply: retcode (220); Msg: Ready to start TLS | |
send: 'ehlo ip-172-31-5-44.ap-southeast-1.compute.internal\r\n' | |
reply: '250-email-smtp.amazonaws.com\r\n' | |
reply: '250-8BITMIME\r\n' | |
reply: '250-SIZE 10485760\r\n' | |
reply: '250-STARTTLS\r\n' | |
reply: '250-AUTH PLAIN LOGIN\r\n' | |
reply: '250 Ok\r\n' | |
reply: retcode (250); Msg: email-smtp.amazonaws.com | |
8BITMIME | |
SIZE 10485760 | |
STARTTLS | |
AUTH PLAIN LOGIN | |
Ok | |
send: 'AUTH PLAIN xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\n' | |
reply: '235 Authentication successful.\r\n' | |
reply: retcode (235); Msg: Authentication successful. | |
send: 'mail FROM:<from@domain.com> size=194\r\n' | |
reply: '250 Ok\r\n' | |
reply: retcode (250); Msg: Ok | |
send: 'rcpt TO:<to@domain.com>\r\n' | |
reply: '250 Ok\r\n' | |
reply: retcode (250); Msg: Ok | |
send: 'data\r\n' | |
reply: '354 End data with <CR><LF>.<CR><LF>\r\n' | |
reply: retcode (354); Msg: End data with <CR><LF>.<CR><LF> | |
data: (354, 'End data with <CR><LF>.<CR><LF>') | |
send: '<Message Text>' | |
reply: '554 Message rejected: Email address is not verified.\r\n' | |
reply: retcode (554); Msg: Message rejected: Email address is not verified. | |
data: (554, 'Message rejected: Email address is not verified.') | |
send: 'rset\r\n' | |
reply: '250 Ok\r\n' | |
reply: retcode (250); Msg: Ok | |
Traceback (most recent call last): | |
File "emailscripttest.py", line 56, in <module> | |
server.sendmail(fromaddr, toSuccessAddrs, msgSuccess) | |
File "/usr/lib/python2.7/smtplib.py", line 739, in sendmail | |
raise SMTPDataError(code, resp) | |
smtplib.SMTPDataError: (554, 'Message rejected: Email address is not verified.') | |
ubuntu@ip-172-31-5-44:~$ |
Notice that it clearly says 554, 'Message rejected: Email address is not verified.'
Tip: The production access allows to send email to any email id but it restricts that the "from" address at least must be verified if not the domain. This was the culprit in our case as the from email id was not verified.
No comments:
Post a Comment