-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.py
41 lines (33 loc) · 1.37 KB
/
content.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
import smtplib, os, server, file
from email import encoders
from email.mime.base import MIMEBase
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
file = file.File()
serv = server.Server()
class Messenger():
def __init__(self):
self.attached = False
self.files_attached = 0
def mail_content(self, my_email, my_pswd, dest_email, subject, message):
for email in dest_email:
msg = MIMEMultipart()
msg['From'] = my_email
msg['To'] = email
msg['Subject'] = subject
msg.attach(MIMEText(message, 'plain'))
while self.attached == False:
if self.files_attached == 0:
any_file = str(input("\nAdd file (yes, no): "))
else:
any_file = str(input("\nAdd more (yes, no): "))
if any_file.lower().startswith('y'):
if file.annex != False:
msg.attach(file.annex())
self.files_attached += 1
elif any_file.lower().startswith('n'):
self.attached = True
else:
print('Invalid input')
print('\nSending email with {0} attachments...'.format(self.files_attached), end='')
serv.deliver(msg, my_email, my_pswd, dest_email)