-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsendmail.py
40 lines (28 loc) · 949 Bytes
/
sendmail.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
from email.message import EmailMessage
import smtplib
import random
from random import choice
import time
import ssl
from dominate.tags import body
# workd only for gmail
PASSWORD ='app_password_by_gmail'
email_sender = 'username@gmail.com'
#use this or choose each digit of otp
class generate_otp:
def __init__(self):
self.otp = random.randint(110000, 999999)
def get_otp(self):
return self.otp
class send_mail:
def __init__(self,email, body):
self.email = email
self.body = body
self.sendmail()
def sendmail(self):
connection = smtplib.SMTP("smtp.gmail.com")
connection.starttls()
connection.login(user=email_sender, password=PASSWORD)
connection.sendmail(from_addr=email_sender, to_addrs=self.email, msg=self.body)
connection.close()
# send_mail('2100520100163@ietlucknow.ac.in', "this is body")