Last active
July 19, 2020 21:28
-
-
Save agentzex/d4adbe2daf8ed2571435ab3400a726f4 to your computer and use it in GitHub Desktop.
HiTechProblems email sender
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
# -*- coding: utf-8 -*- | |
#use python3 (tested on 3.7) | |
import smtplib | |
from email.mime.multipart import MIMEMultipart | |
from email.mime.text import MIMEText | |
from email.utils import formatdate | |
fromaddr = '[email protected]' | |
username = fromaddr | |
password = 'yourpassword' | |
recipients = ["[email protected]", "[email protected]"] | |
def send(subject, body): | |
server = smtplib.SMTP('smtp.gmail.com:587') | |
server.starttls() | |
server.login(username, password) | |
contact_msg = MIMEMultipart() | |
contact_msg['From'] = fromaddr | |
contact_msg['To'] = ",".join(recipients) | |
contact_msg['Date'] = formatdate(localtime=True) | |
contact_msg['Subject'] = subject | |
contact_msg.attach(MIMEText(body)) | |
server.sendmail(fromaddr, recipients, contact_msg.as_string()) | |
server.close() | |
if __name__ == '__main__': | |
send("איפה החבילות???" , "כל החבילות שלי נעלמו! אחלה דואר ישראל") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment