-
Notifications
You must be signed in to change notification settings - Fork 105
/
Copy pathbasic_email_sender.py
39 lines (33 loc) · 1005 Bytes
/
basic_email_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
import smtplib
import re
regex = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b'
def check_email(email):
if(re.fullmatch(regex, email)):
return True
else:
return False
server = smtplib.SMTP_SSL("smtp.gmail.com", 465)
while True:
email = str(input("Enter your email address: "))
password = str(input("Enter your Password: "))
if not check_email(email):
continue
else:
try:
server.login(email, password)
print("Successfully Logged In")
break
except:
print("Unsuccessfull login please try again")
continue
while True:
try:
r_email = str(input("Enter Reciever's Email: "))
message = str(input("Enter the Message: "))
server.sendmail(email,r_email,message)
print("Message sent Successfully")
break
except:
/// ookk
print("Failed! \nPlease try again ")
continue