28 lines
624 B
Python
28 lines
624 B
Python
#!/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)
|
|
|