-
Notifications
You must be signed in to change notification settings - Fork 0
/
mailing.py
executable file
·55 lines (46 loc) · 2.31 KB
/
mailing.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
import random
import smtplib
from email.message import EmailMessage
import imghdr
from rand_pass_gen import generate_random_password,generate_2FA_code
EMAIL_ADDRESS='[email protected]' # email id to send your users email
EMAIL_PASSWORD='yourmailpassword' # password of that email id (do not forget to disbale all 2 FA authentication as SMTP needs free access to your mail account)
def welcome(a,b): # welcome email for newly registered users
global EMAIL_ADDRESS,EMAIL_PASSWORD,msg
msg=EmailMessage()
msg['Subject']='Welcome to Arcade world'
msg['From']=EMAIL_ADDRESS
msg['To']=a
twofa=generate_2FA_code()
msg.set_content(f'''Dear {b},\nRelive your childhood with a game that will give make you feel nostalgic and experience euphoria!
\nEnjoy the Game\nHere is your Confirmation code- {twofa}\nWith Warm Regards,\nNihal T M.''')
with smtplib.SMTP_SSL('smtp.gmail.com',465) as smtp:
smtp.login(EMAIL_ADDRESS,EMAIL_PASSWORD)
smtp.send_message(msg)
return twofa
def send_pass(a,b,c): # forgot password email
global EMAIL_ADDRESS,EMAIL_PASSWORD,msg
msg=EmailMessage()
msg['Subject']='Arcade world password Reset'
msg['From']=EMAIL_ADDRESS
msg['To']=a
new_pass=c
msg.set_content(f'''Dear {b},\nWe realised that you wanted to login to your favourite Arcade games but could not as you had forgotten the password.
\nSo here is your password- {new_pass}\nPlease do not forget to delete this email once you have logged in\nEnjoy the Game\nWith Warm Regards,\nNihal T M.''')
with smtplib.SMTP_SSL('smtp.gmail.com',465) as smtp:
smtp.login(EMAIL_ADDRESS,EMAIL_PASSWORD)
smtp.send_message(msg)
return new_pass
def two_FA(a,b): # two factor authentication email
global EMAIL_ADDRESS,EMAIL_PASSWORD,msg
msg=EmailMessage()
msg['Subject']='Arcade world 2FA'
msg['From']=EMAIL_ADDRESS
msg['To']=a
twofa=generate_2FA_code()
msg.set_content(f'''Dear {b},\nWe realised that you wanted to login to your Arcade world.
\nSo here is the 2FA code- {twofa}\nEnjoy the Game\nWith Warm Regards,\nNihal T M.''')
with smtplib.SMTP_SSL('smtp.gmail.com',465) as smtp:
smtp.login(EMAIL_ADDRESS,EMAIL_PASSWORD)
smtp.send_message(msg)
return twofa