Skip to content

Instantly share code, notes, and snippets.

@agentzex
Last active July 19, 2020 21:28
Show Gist options
  • Save agentzex/d4adbe2daf8ed2571435ab3400a726f4 to your computer and use it in GitHub Desktop.
Save agentzex/d4adbe2daf8ed2571435ab3400a726f4 to your computer and use it in GitHub Desktop.
HiTechProblems email sender
# -*- 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