-
Notifications
You must be signed in to change notification settings - Fork 1
/
mail_sender.py
50 lines (42 loc) · 1.58 KB
/
mail_sender.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
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.application import MIMEApplication
from os.path import basename
import time
import locale
def sendMail(file_name, user):
attachment = "/scans/" + user + "/" + file_name
me = "[email protected]"
you = user + "@csh.rit.edu"
text = MIMEText(
"Your scan is complete! \nIf something is wrong with this email, check out the wiki to learn another way to get your file!")
msg = MIMEMultipart()
msg.attach(text)
f = open(attachment, "rb")
part = MIMEApplication(f.read(), Name=basename(attachment))
part["Content-Disposition"] = 'attachment; filename="%s"' % basename(attachment)
msg.attach(part)
msg["Subject"] = "Here is your completed scan!"
msg["From"] = me
msg["To"] = you
msg.preamble = "Here is your completed scan!"
s = smtplib.SMTP('mail.csh.rit.edu')
s.sendmail(me, you, msg.as_string())
print("[" + time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()) + "] Email message sent")
s.quit()
def goodbyeMail(user):
me = "[email protected]"
you = user + "@csh.rit.edu"
msg = MIMEMultipart()
text = MIMEText("Your scan backup has been deleted, for more info see the wiki")
msg.attach(text)
msg["Subject"] = "Scan Backup Deleted"
msg["From"] = me
msg["To"] = you
s = smtplib.SMTP('mail.csh.rit.edu')
s.sendmail(me, you, msg.as_string())
print("[" + time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()) + "] Email message sent")
s.quit()
if __name__ == "__main__":
pass