Home > Article > Backend Development > Python httplib, detailed explanation of how to use smtplib
Use httplib to access a certain url and then get the returned content and use smtplib to send the email script example code
Example 1: Use httplib to access a certain url and then get the returned content:
import httplib
conn=httplib.HTTPConnection(" www.cnblogs.com")
conn.request("GET" , "/coderzh/archive/2008/05/13/1194445.html")
r=conn.getresponse()
print r.read() #Get all content
Example 2: Use smtplib to send email
import smtplib
smtpServer = 'smtp.xxx.com'
fromaddr = 'foo@xxx.com'
toaddrs = 'your@xxx.com'
msg = 'Subject: xxxxxxxxx'
server = smtplib.SMTP(smtpServer)
server.sendmail(fromaddr, toaddrs, msg)
server.quit( )
The above is the detailed content of Python httplib, detailed explanation of how to use smtplib. For more information, please follow other related articles on the PHP Chinese website!