-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEmail.py
56 lines (45 loc) · 1.62 KB
/
Email.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
import smtplib
email = input('which email do you have??\n').lower()
while(email != 'gmail' and email != 'outlook' and email != 'yahoo'):
email = input('Enter one of the following:\n1.Gmail\n2.Outlook\n3.Yahoo\n\n').lower()
if(email == 'gmail'):
email = 'smtp.gmail.com'
domain = '@gmail.com'
elif(email == 'outlook'):
email = 'smtp-mail.outlook.com'
domain = '@outlook.com'
elif(email == 'yahoo'):
email = 'smtp.mail.yahoo.com'
domain = '@yahoo.com'
conn = smtplib.SMTP(email, 587) # smtp.gmail.com
# smtp-mail.outlook.com
# smtp.mail.yahoo.com
conn.ehlo() # Starting the connection
conn.starttls() # Encrypting the connection
emailid = input('Enter Email address'+'('+domain+')'+'...\n')
emailid+=domain
password = input('Enter your password...\n')
while(True):
try:
conn.login(emailid,password)
print('\nLogged in:)')
break
except smtplib.SMTPAuthenticationError:
print('\n\nIncorrect email or password\n')
print('Is this your email address?\n',emailid,'\n')
yn = input().lower()
if(yn == 'no'):
emailid = input('Re-enter your email address\n')
password = input('Enter password\n')
to=input('Who do you want to send the email to?\n')
subject=input('Subject : ')
text=input('Enter the body of the email...\n')
message = 'Subject: '+subject+'\n\n'+text
print('\n\n\n'+message,'\n\nsend?')
send=input()
if send=='yes':
conn.sendmail(emailid,to,message)
print('\nsent!')
else:
print('ok')
#conn.sendmail(from, to, message)