Trying to send an email properly without using gmail. I'm using Mail.com as a provider with my two alternate accounts:
- jonathan.smith@email.com
- tyler1@programmer.net
I've looked on different post on how to send an email; and they end up at the same. I have a feeling it's either that the SMTP port is down on mail.com because i've tried the credentials on mail.com login website and the credentials are correct. What's wrong here? Is the website login credential different to the SMTP login credential?
code:
import smtplib, ssl
port = 587
smtp_server = "smtp.mail.com"
sender_email = "jonathan.smith@email.com"
receiver_email = "tyler1@programmer.net"
password = "-------" # for security reasons
message = """\
Subject: Hello World
This message is sent from Python."""
context = ssl.create_default_context()
with smtplib.SMTP(smtp_server, port) as server:
server.ehlo() # Can be omitted
server.starttls(context=context)
server.ehlo() # Can be omitted
server.login(sender_email, password)
server.sendmail(sender_email, receiver_email, message)