-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend_email.py
More file actions
27 lines (22 loc) · 762 Bytes
/
Copy pathsend_email.py
File metadata and controls
27 lines (22 loc) · 762 Bytes
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
import sys
import smtplib
from email.mime.text import MIMEText
def send_email(message):
sender = 'yichen.charles.cai@outlook.com'
recipient = 'charlestsai0919@gmail.com'
subject = 'Message from Webpage'
body = message
msg = MIMEText(body)
msg['Subject'] = subject
msg['From'] = sender
msg['To'] = recipient
try:
with smtplib.SMTP_SSL('smtp.gmail.com', 465) as server:
server.login(sender, "gvll tcmm lkmh sadp")
server.sendmail(sender, recipient, msg.as_string())
print('Message sent successfully. Thank you!')
except Exception as e:
print(f'Sorry, messaging service is currently down: {e}')
if __name__ == "__main__":
message = sys.argv[1]
send_email(message)