Use Httplib to access a URL and then get the returned content and script instance code to send the message using Smtplib
Example one: Use Httplib to access a URL and get the returned content:
Code highlighting produced by Actipro CodeHighlighter (
Based on the Smtplib package made, but in practice found a do not know is not considered to be smtplib left a pit, A Socket.gaierror exception is thrown when a message is sent while the network is disconnected, but the exception is not caught in
Hey realized the use of 163 sent to QQ function, left two questions:1. The recipient list will error;Update: Because list[] will pass the past a real []list, changed to the following:Before:maillist=['[email protected]','[email protected]'] msg[' to'
Function: Smtplib module is to send e-mail through mail server, is the implementation of SMTP client, Support message format: text, HTML, Image, Excel and so on.1 #!/usr/bin/env python2 #Coding:utf-83 ImportSmtplib4 Importstring5Host ="smtp.qq.com"
Example 1: Use httplib to access a URL and obtain the returned content:
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
Import
HttplibConn
=
Httplib. httpconnection (
"
Www.cnblogs.com
Python's Stmplib module enables the sending of messages, which can be emulated by an SMTP client. The python2.3 or later version defaults to the Smtplib module, eliminating the need for additional installation.I. Common classes and methods of
Example one: Use Httplib to access a URL and get what it returns:
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->
Import HttplibConn=Httplib. Httpconnection
Use httplib to access a url and then obtain the returned content and the script instance code for sending an email using smtplib. Example 1: Use httplib to access a url and then obtain the returned content:
Code highlighting produced by Actipro
function: send e-mail via mail server, Smtplib is an implementation of SMTP client, Support message format: text, HTML, Image, EXCEL1. Ordinary text mail#!/usr/bin/env python# coding:utf-8import smtplibimport stringhost = " Smtp.qq.com "
This example describes how Python uses the Smtplib module to deliver mail via Gmail. Share to everyone for your reference. The implementation method is as follows:
Import Smtplibfrom Email. Mimemultipart Import mimemultipartfrom Email. Mimetext
Example one: Use Httplib to access a URL and get the returned content:
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
Import
HttplibConn
=
Httplib. Httpconnection
Send failed Error 1:smtplib. Smtpauthenticationerror:When we use Python to send a message, the custom client logs in based on the user name and password, and then uses the SMTP service to send the message, and the mailbox is not turned on by default,
Copy Code code as follows:
#!/usr/bin/python
# Encoding=utf-8
# Filename:send_email.py
From Email.mime.image import Mimeimage
From Email.mime.multipart import Mimemultipart
From Email.mime.text import Mimetext
Import Smtplib
Class
The smtplib module is the implementation of the smtp Simple Mail transmission protocol client. For the sake of universality, sometimes attachments or images are required to be sent and the content is loaded using email. mime. The Code is as follows:
recently added a feature in the Siomp system, that is, automatically send the message with an attachment to the specified mailbox, found in the Sending times wrong: Error message: STARTTLS extension not supported by server. It is very strange, but
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.