I am trying to use smtplib for sending mails in python 2.7. The below code is pretty simple:
import smtplib
def main(argv=None):
sender = '[email protected]'
receivers = ['[email protected]']
message = """
This is a test e-mail message.
"""
smtpObj = smtplib.SMTP('[email protected]',25)
smtpObj.login('abc', 'pwd')
smtpObj.sendmail(sender, receivers, message)
print "Successfully sent email"
if __name__ == '__main__':
main()
Now when I execute the below code, I keep getting this exception:
smtplib.SMTPAuthenticationError: (535, '5.7.3 Authentication unsuccessful').
Kindly advise.
Thanks,
Actually, when I tried executing the same statements on python console, I came to know that the password was incorrect and it was due to different character encoding.
For all other users, refrain yourself from copy paste