-
Notifications
You must be signed in to change notification settings - Fork 0
/
mail.py
executable file
·48 lines (35 loc) · 923 Bytes
/
mail.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
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 23 17:51:46 2019
@author: Mansi Shukla
"""
# Python code to illustrate Sending mail from
# your Gmail account
import smtplib
import datetime
import time
# creates SMTP session
def un_mailfunc():
s = smtplib.SMTP('smtp.gmail.com', 587)
# start TLS for security
s.starttls()
# Authentication
s.login("mansi.shukla2017@vitstudent.ac.in","jailakshmi")
# message to be sent
ts = time.time()
st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
print(st)
subject = "Re - Unauthorized Access"
text = """
Hello Admin,\n
User has tried to enter a private file\n
At """+str(st)+"""
Thanks,
From,
System
"""
message = 'Subject:{} \n\n\n {}'.format(subject,text)
# sending the mail
s.sendmail("mansi.shukla2017@vitstudent.ac.in", "mansishukla2505@gmail.com", message, )
# terminating the session
s.quit()