-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmailer.py
More file actions
39 lines (31 loc) · 1.06 KB
/
Copy pathmailer.py
File metadata and controls
39 lines (31 loc) · 1.06 KB
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
34
35
36
37
38
39
# Email Libraries
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import os
""" Cisco Related emails are currently sent out from this email address"""
GMAIL = "ciscointerncorner@gmail.com"
try:
password = os.environ["PASSWORD"]
except BaseException:
print("Mail Server is offline. Please load password to continue...")
def send_mail(email, subject, text):
# Generate Message
msg = MIMEMultipart()
msg['From'] = "InternCorner@PasswordReset"
msg["To"] = email
msg["Subject"] = subject
body = "Hi from the Intern Corner Team! \n"
body += "You recently requested a password reset." \
"Here is your verification code: \n"
body += text
# Edit this attribute for richer email text
msg.attach(MIMEText(body, 'plain'))
# Issue server connection
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(GMAIL, password)
text = msg.as_string()
server.sendmail("InternCorner@PasswordReset",
email, text)
server.quit()