forked from ErikaAzabache/One-City-at-a-Time
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyemail.py
32 lines (24 loc) · 1.37 KB
/
myemail.py
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
import os
import sys
import smtplib
def send_email(receiver, activation_number, subject):
my_pass = os.environ['DARKBOLI_PASSWORD']
receiver_email = receiver
sender_email = '[email protected]'
sender_pwd = my_pass
smtpserver = smtplib.SMTP('darkboli.net', 587) #not self hosted.
smtpserver.ehlo() #Identify yourself to an ESMTP server using EHLO
smtpserver.starttls() #Requests the mail server to start TLS/SSL negotiation and protect the connection with security layer.
smtpserver.login('onecity', sender_pwd)
if subject=='activation':
msg_header = 'To:' + receiver_email + '\n' + 'From: ' + sender_email + '\n' + 'Subject: Email Confirmation \n'
msg_intro = '\n Thank you for registering. To activate your account click here: \n\n'
activation_link = "http://localhost:5000/activation/" + str(activation_number)
if subject=='forgot_pass':
msg_header = 'To:' + receiver_email + '\n' + 'From: ' + sender_email + '\n' + 'Subject: Reset Password \n'
msg_intro = '\n You requested a password reset. To continue with this process, please click here: \n\n'
activation_link = "http://localhost:5000/reset/" + str(activation_number)
msg_content = msg_intro + activation_link
msg = msg_header + msg_content
smtpserver.sendmail(sender_email, receiver_email, msg)
smtpserver.close()