-
-
Save guyarad/91f462d103dfb9a5d4568d1cd1f09579 to your computer and use it in GitHub Desktop.
HiTechProblems email sender
This file contains 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 = 'youremail@gmail.com' | |
username = fromaddr | |
password = 'yourpassword' | |
recipients = ["nobodysthere@israelpost.co.il", "ceo@israelpost.co.il"] | |
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