Created
September 29, 2021 13:41
-
-
Save naimurhasan/10198c8c7bfa1d20248ac269313dca30 to your computer and use it in GitHub Desktop.
smtp email send with mail.py
This file contains hidden or 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
import smtplib, ssl | |
from email.mime.text import MIMEText | |
from email.mime.multipart import MIMEMultipart | |
from email.mime.base import MIMEBase | |
import key | |
port = 587 # For starttls | |
smtp_server = "send.one.com" | |
sender_email = "[email protected]" | |
receiver_email = "[email protected]" | |
password = key.PASSWORD | |
msg = MIMEMultipart() | |
msg['From'] = sender_email | |
msg['To'] = receiver_email | |
msg['Subject'] = 'SMTP Test' | |
body = 'Hi there, this message was sent from python.' | |
msg.attach(MIMEText(body,'plain')) | |
text = msg.as_string() | |
print('text', text) | |
server = smtplib.SMTP(smtp_server,587) | |
server.starttls() | |
server.login(sender_email, password) | |
server.sendmail(sender_email,[receiver_email],text) | |
server.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment