forked from AdityaMitra5102/FIDO-Payments
-
Notifications
You must be signed in to change notification settings - Fork 0
/
emailoperations.py
56 lines (49 loc) · 1.76 KB
/
emailoperations.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import smtplib
import random
import string
import io
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from flask import *
senderacc="[email protected]"
senderpass="AccountPassword1"
server='smtp.gmail.com'
port=587
def genOtp():
characters = string.digits
password = ''.join(random.choice(characters) for i in range(4))
return password
def sendEmail(id,otp):
s = smtplib.SMTP(server,port)
s.starttls()
s.login(senderacc, senderpass)
message = "Subject:Authorization OTP\n\nThe OTP for Authorization is "+otp
s.sendmail(senderacc, id, message)
s.quit()
def sendEmailLink(id,lnk,ua,loc=""):
s = smtplib.SMTP(server,port)
s.starttls()
s.login(senderacc, senderpass)
message = "Subject:Authorization Link\n\nOpen this link from the device you are trying to log in. \n"
message=message+"If you are not trying to log in, ignore this mail and do not forward it to anyone \n"
message=message+"Please be sure you recognize this device\n"
message=message+"Browser: "+ua.browser+"\n"
message=message+"Platform: "+ua.platform+"\n"
message=message+loc+"\n\n"
message=message+lnk
s.sendmail(senderacc, id, message)
s.quit()
def sendEmailNotifAdd(id,tname,tdate,upl,name):
s = smtplib.SMTP(server,port)
s.starttls()
s.login(senderacc, senderpass)
message = "Subject:Medical Report Added\n\nTest report: "+tname+" of "+name+" tested on "+tdate+" uploaded by "+upl
s.sendmail(senderacc, id, message)
s.quit()
def sendEmailTokenAdd(id,hname,exp):
s = smtplib.SMTP(server,port)
s.starttls()
s.login(senderacc, senderpass)
message = "Subject:Token Provisioned\n\nTemporary token provisioned to "+hname+" and is expiring on "+exp
s.sendmail(senderacc, id, message)
s.quit()