Skip to content

Commit 0a098b8

Browse files
Add smtplib
Send & manage emails automatically by this library
1 parent 354049b commit 0a098b8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

_smtplib.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import smtplib
2+
3+
USERNAME = 'username@gmail.com'
4+
PASSWORD = ''
5+
SERVER = 'smtp.gmail.com'
6+
PORT = 465 # 587 for TLS
7+
8+
TO = 'another.username@gmail.com'
9+
SUBJECT = 'Subject'
10+
TEXT = 'your text'
11+
MESSAGE = """To: {to}
12+
Subject: {subject}
13+
{body}"""
14+
15+
server = smtplib.SMTP_SSL(SERVER, PORT)
16+
server.login(USERNAME, PASSWORD)
17+
server.sendmail(USERNAME, TO, MESSAGE.format(to=TO, subject=SUBJECT, body=TEXT))
18+
server.close()

0 commit comments

Comments
 (0)