-
Notifications
You must be signed in to change notification settings - Fork 2
/
sendMail.py
35 lines (29 loc) · 1.01 KB
/
sendMail.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
#-------------------------------------------------------------------------------
# Name: sending emails
# Purpose: send emails using gmail
# Author: rakesh kumar
# Created: 18-04-2017
# Copyright: binarynote.com
# Licence: MIT-2.0
#-------------------------------------------------------------------------------
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
def mail():
fromaddr = "[email protected]"
toaddr = "[email protected]"
msg = MIMEMultipart()
msg['From'] = fromaddr
msg['To'] = toaddr
msg['Subject'] = "This is a simple message from python"
body = "Python test mail sending from python program"
msg.attach(MIMEText(body, 'plain'))
server = smtplib.SMTP('smtp.gmail.com',587)
server.ehlo()
server.starttls()
server.ehlo()
server.login('[email protected]','RAMJI00789')
text = msg.as_string()
server.sendmail(fromaddr,toaddr,text)
if __name__ == '__main__':
mail()