-
Notifications
You must be signed in to change notification settings - Fork 0
/
Emailer.py
61 lines (49 loc) · 1.72 KB
/
Emailer.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
50
51
52
53
54
55
56
57
58
59
60
61
import smtplib, getpass
default = '[email protected]'
dad = '[email protected]'
mom = '[email protected]'
Connor = '[email protected]'
Jonah = '[email protected]'
seb = '[email protected]'
names = ['default','dad','mom','Connor','Jonah','seb']
emails = ['[email protected]','[email protected]','[email protected]','[email protected]','[email protected]','[email protected]']
list_length = len(names)
def send_email(recipient):
smtpObj = smtplib.SMTP('smtp.gmail.com', 587)
smtpObj.ehlo()
smtpObj.starttls()
print('which email do you want to send from?')
sender = str(input())
if sender == names[0]:
sender = emails[0]
for i in range(0, list_length):
if recipient == names[i]:
recipient = emails[i]
break
while True:
print('Enter your password:')
password = getpass.getpass()
password = str(password)
try:
smtpObj.login(sender, password)
password = None
break
except smtplib.SMTPAuthenticationError:
print('Try again bad password:/')
print('Subject: ')
subject = 'Subject: ' + str(input())
print('Main Body: ')
main_body = str(input())
print('Ending: ')
ending = str(input())
smtpObj.sendmail('[email protected]', recipient, subject + '\n' + main_body + '\n' + ending)
smtpObj.quit()
print('Sent!')
print('Do you want to send an email? Y/n')
answer = str(input())
if answer == ' ' or answer == 'y' or answer == 'Y':
print('Who do you want to send the email to?')
person = str(input())
send_email(person)
elif answer == 'n' or answer == 'N':
print("Ok have a nice day :)")