Reputation: 845
I am not at all familiar with SMTP
but I am working on sending emails
through Python
code. I have the code but I need to pass SMTP
host name
for it to actually work. Is there any service which provides a free SMTP
service that I leverage for testing out my code? I looked around to create my own SMTP server
but couldn't find something that provides a step by step guide to create a SMTP server
. I want to create a free server(or if there is any free service) that will provide me with a host name(ip
address) so that I can put that host name in my python code and execute it from any machine.
If anyone can point me in the right direction it will be helpful.
Upvotes: 4
Views: 3302
Reputation: 124
You need service like https://mailtrap.io/. You'll get SMTP server address (eventually port number) that you point your application to. All e-mails produced by your application will be then intercepted by mailtrap (thus not delivered to the real To:
address).
They offer free variant that seems to be suitable for your needs.
Upvotes: 2
Reputation: 3613
import smtplib
username = 'user'
password = 'pwd'
from_addr = '[email protected]'
to_addrs = '[email protected]'
msg = "\r\n".join([
"From: [email protected]",
"To: [email protected]",
"Subject: subject",
"",
"message"
])
server = smtplib.SMTP('smtp.gmail.com:587')
server.ehlo()
server.starttls()
server.login(username, password)
server.sendmail(from_addr, to_addrs, msg)
server.quit()
You can use mutt
linux command also here.
See :
https://docs.python.org/3/library/smtplib.html
https://support.google.com/a/answer/176600?hl=en
Upvotes: 4