-
Notifications
You must be signed in to change notification settings - Fork 0
/
emailing.py
48 lines (31 loc) · 1.29 KB
/
emailing.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
import smtplib, ssl,datetime
sender= "hackathon2juet@gmail.com"
password="#Hackathon2022"
def email_pin(email,pin):
port = 465
now=datetime.datetime.now()
date=now.strftime('%m/%d/%Y').replace('/0','/')
if(date[0]=='0'):
date=date[1:]
subject="Pin for your attendance app "
text="\nYour pin for attendance app is "+str(pin)
message ='Subject: {}\n\n{}'.format(subject, text)
context = ssl.create_default_context()
print("Starting to send")
with smtplib.SMTP_SSL("smtp.gmail.com", port, context=context) as server:
server.login(sender, password)
server.sendmail(sender, email, message)
print("sent email!")
def send_email(receiver_mail,attendance):
port = 465
now=datetime.datetime.now()
date=now.strftime('%m/%d/%Y').replace('/0','/')
subject="Attendance on "+str(date)
text="\nYour attendance is marked "+attendance
message ='Subject: {}\n\n{}'.format(subject, text)
context = ssl.create_default_context()
print("Starting to send")
with smtplib.SMTP_SSL("smtp.gmail.com", port, context=context) as server:
server.login(sender, password)
server.sendmail(sender, receiver_mail , message)
print("sent email!")