Welcome, guest | Sign In | My Account | Store | Cart

sending gmail though your python code

Python, 18 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#Sending an email through gmail using Python - Raghuram Reddy
import smtplib
fromaddr = 'raghuramgreddy@gmail.com'
toaddrs = 'raghuramgreddy@gmail.com'
msg = 'Email message from PYTHON Raghuram app'

#provide gmail user name and password
username = 'gmailUserName'
password = 'gmailPassword'

# functions to send an email
server = smtplib.SMTP('smtp.gmail.com:587')
server.ehlo()
server.starttls()
server.ehlo()
server.login(username,password)
server.sendmail(fromaddr, toaddrs, msg)
server.quit()

5 comments

Trent Mick 13 years, 8 months ago  # | flag

See also (other recipes talking to gmail): http://code.activestate.com/search/recipes/#q=gmail

D.A. 13 years, 6 months ago  # | flag

Thanks! I had a lot of fun playing around with this code.

Raghuram (author) 11 years, 1 month ago  # | flag

Please change the email if you are using this code to avoid spam.

Thanks, Raghuram Reddy Gottimukkula

Raghuram (author) 11 years, 1 month ago  # | flag

"10060 views for this recipe???". Inspired to post more.

nagaraj 10 years, 10 months ago  # | flag

thanks

Created by Raghuram on Wed, 25 Aug 2010 (MIT)
Python recipes (4591)
Raghuram's recipes (1)

Required Modules

Other Information and Tasks