To send an email via local SMTP
If you have a SendMail(Which is a local SMTP server), check whether it is listening as expected
netstat -tuna
You should've noticed that it's listening on the loopback address on port 25
See, If it's listening, you can be able to do this in python to send an email
import smtplib
sender = '[email protected]'
receivers = ['[email protected]']
message = """From: No Reply <[email protected]>
To: Person <[email protected]>
Subject: Test Email
This is a test e-mail message.
"""
try:
smtpObj = smtplib.SMTP('localhost')
smtpObj.sendmail(sender, receivers, message)
print("Successfully sent email")
except SMTPException:
print("Error: unable to send email")
Want to learn more about Python? Come, and join the Python Course course