GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Python-Automation/mail.py at master · kjsce-codecell/Python-Automation Expand file tree/ Copy pathmail.pyMore file actions 37 lines (30 loc) · 1.04 KB / Copy pathmail.pyFile metadata and controls37 lines (30 loc) · 1.04 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart from email.mime.image import MIMEImage import smtplib def sendmail(to_email, message, image_path, payment_status): from_email = "" msg = MIMEMultipart('alternative') msg['Subject'] = "Python Automation Workstop" msg['From'] = from_email msg['To'] = to_email content = MIMEText(message, 'plain') msg.attach(content) # This example assumes the image is in the given directory if payment_status == 'paid': fp = open(image_path, 'rb') msgImage = MIMEImage(fp.read()) fp.close() msg.attach(msgImage) response = {} try: with smtplib.SMTP("smtp.gmail.com", 587) as s: s.starttls() s.login(from_email, "") print("Sending Mail:", to_email) s.sendmail(from_email, to_email, msg.as_string()) response['email_status'] = "Success" except Exception as err: print(err) response['email_status'] = "Failed" return response |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |