Add Backup/send_mail.py
This commit is contained in:
27
Backup/send_mail.py
Normal file
27
Backup/send_mail.py
Normal file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env python3
|
||||
import smtplib
|
||||
from email.message import EmailMessage
|
||||
import sys
|
||||
|
||||
def send_mail(subject, body, to_email):
|
||||
msg = EmailMessage()
|
||||
msg.set_content(body)
|
||||
msg['Subject'] = subject
|
||||
msg['From'] = GMAIL_USER
|
||||
msg['To'] = to_email
|
||||
|
||||
with smtplib.SMTP('mail.com', 587) as server:
|
||||
server.starttls()
|
||||
server.login(GMAIL_USER, GMAIL_PASS)
|
||||
server.send_message(msg)
|
||||
|
||||
if __name__ == "__main__":
|
||||
GMAIL_USER = "email@test.com"
|
||||
GMAIL_PASS = "passwd"
|
||||
|
||||
subject = sys.argv[1]
|
||||
body = sys.argv[2]
|
||||
to_email = sys.argv[3]
|
||||
|
||||
send_mail(subject, body, to_email)
|
||||
|
Reference in New Issue
Block a user