-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgmail_connector.py
More file actions
33 lines (27 loc) · 793 Bytes
/
gmail_connector.py
File metadata and controls
33 lines (27 loc) · 793 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
28
29
30
31
32
33
"""
This is the gmail_connector module.
This module sends a mail message to the user
"""
# Imports
import smtplib
def SendMessage(to, text):
# Vars
gmail_user = "ns.404.notfound@gmail.com"
gmail_pwd = "123456789AA"
FROM = "NS 404"
TO = to if type(to) is list else [to]
SUBJECT = "Melding fietsenstalling"
TEXT = text
# Prepare actual message
message = """From: %s\nTo: %s\nSubject: %s\n\n%s
""" % (FROM, ", ".join(TO), SUBJECT, TEXT)
try:
server = smtplib.SMTP("smtp.gmail.com", 587)
server.ehlo()
server.starttls()
server.login(gmail_user, gmail_pwd)
server.sendmail(FROM, TO, message)
server.close()
print("successfully sent the mail")
except:
print("failed to send mail")