forked from kal179/Beginners-Python-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendingEmailsInPython.py
32 lines (24 loc) · 962 Bytes
/
sendingEmailsInPython.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
import smtplib
# REMEMBER : dont send mails through public computers or servers
# connecting to googles serevrs
serverToLogin = smtplib.SMTP('smtp.gmail.com' , 587)
# Username
userName = str(input('Username for Gmail : '))
# password
password = str(input('Password Of Account : '))
# Logging in
serverToLogin.login(userName , password)
def sendMail():
yourEmail = str(input('Your Email Address : ')) # senders email address
toSendEmail = str(input('Receivers Email Address')) # receivers email address
messageHead = str(input('Message Head : ')) # Message head
messageBody = str(input('Message : ')) # main message
fullMessage = messageHead + '\n' + messageBody # full message
serverToLogin.sendmail(yourEmail , toSendEmail , fullMessage) # sending email address through server
while True:
toSendOrNot = str(input('Send or End : '))
if toSendOrNot == 'Send':
print('\n')
print(sendMail())
else :
quit()