How to send emails through qq mailbox in python3
This time I will bring you python3 How to send emails through qq mailbox, what are the precautions for sending emails through qq mailbox in python3, the following is a practical case, let’s take a look one time.
Understand SMTP of qq mailbox
QQ mailbox POP3 and SMTP server address settings are as follows:
Mailbox POP3 server (port 995) SMTP server (port 465 or 587)
qq.com pop.qq.com smtp.qq.com
The SMTP server requires authentication.
1. Turn on the smtp service of qq mailbox
How to turn on the POP3/SMTP/IMAP function?
In order to ensure the security of users' mailboxes, QQ mailboxes are set with POP3/SMTP/IMAP switches. The system default setting is "off". Please "enable" when users need these functions. First, log in to your email and go to Settings - Account;
Then, in the "Account" settings, find the setting item and set it. As follows:
Finally, save the settings and open the corresponding service.
2. Code
import smtplibfrom email.mime.text import MIMETextfrom email.utils import formataddr my_sender='XXXXXXX@qq.com' # 发件人邮箱账号my_pass = 'xxxxxxxxxxxx' # 发件人邮箱密码(当时申请smtp给的口令)my_user='xxxxxx@xx.com' # 收件人邮箱账号,我这边发送给自己def mail(): ret=True try: msg=MIMEText('填写邮件内容','plain','utf-8') msg['From']=formataddr(["发件人昵称",my_sender]) # 括号里的对应发件人邮箱昵称、发件人邮箱账号 msg['To']=formataddr(["收件人昵称",my_user]) # 括号里的对应收件人邮箱昵称、收件人邮箱账号 msg['Subject']="邮件主题-测试" # 邮件的主题,也可以说是标题 server=smtplib.SMTP_SSL("smtp.qq.com", 465) # 发件人邮箱中的SMTP服务器,端口是465 server.login(my_sender, my_pass) # 括号中对应的是发件人邮箱账号、邮箱密码 server.sendmail(my_sender,[my_user,],msg.as_string()) # 括号中对应的是发件人邮箱账号、收件人邮箱账号、发送邮件 server.quit()# 关闭连接 except Exception:# 如果 try 中的语句没有执行,则会执行下面的 ret=False ret=False return ret ret=mail()if ret: print("邮件发送成功")else: print("邮件发送失败")
Note: If the recipient address is wrong, the code will still prompt "Email sent successfully". If the address is wrong, you will receive "From qq" in your qq mailbox .com's return letter"
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to the php Chinese website Other related articles!
Related reading:
H5 production performance change line chart
What is the difference between python3 and JS
The above is the detailed content of How to send emails through qq mailbox in python3. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The syntax for adding columns in different database systems varies greatly, and varies from database to database. For example: MySQL: ALTER TABLE users ADD COLUMN email VARCHAR(255); PostgreSQL: ALTER TABLE users ADD COLUMN email VARCHAR(255) NOT NULL UNIQUE;Oracle: ALTER TABLE users ADD email VARCHAR2(255);SQL Server: ALTER TABLE users ADD email VARCH

Redis provides five core memory data types: String: basic string storage, supporting incremental/decreasing operations. List: Bidirectional linked list, efficient insertion/deletion operation. Set: Unordered set, used for deduplication operations. Hash: Key-value pair storage, suitable for storing structured data. Zset: Ordered set, each element has fractions, and can be sorted by fractions. Choosing the right data type is critical to optimizing performance.

I'm having a tricky problem when doing a mail marketing campaign: how to efficiently create and send mail in HTML format. The traditional approach is to write code manually and send emails using an SMTP server, but this is not only time consuming, but also error-prone. After trying multiple solutions, I discovered DUWA.io, a simple and easy-to-use RESTAPI that helps me create and send HTML mail quickly. To further simplify the development process, I decided to use Composer to install and manage DUWA.io's PHP library - captaindoe/duwa.

To ensure that your Debian mail server runs stably, an effective monitoring mechanism is required. This article introduces several monitoring methods, including log checking, monitoring tools and alarm system settings. 1. Log monitoring The log files of the Debian mail server are usually located in the /var/log/ directory, such as /var/log/mail.log. Regularly checking these logs can help you identify potential problems in a timely manner. 2. Monitoring tools and script examples The following provides several Bash script examples for monitoring CPU, memory and disk space usage and sending email alarms: 1. CPU usage monitoring: #!/bin/bashTHRESHOLD=80EMAILS="your_emai

Nginx virtual host configuration: Playing around your server garden Have you ever thought about how one server elegantly serves multiple websites at the same time? The answer is the Nginx virtual host configuration. This article will take you into Nginx virtual host configuration tips, allowing you to efficiently manage your "server garden" and avoid some common pitfalls. After reading, you will be able to easily configure the virtual host, understand the mechanism behind it, and write efficient and stable Nginx configuration files. Basic preparation: Don't forget that before starting your toolbox, you need to make sure that Nginx is installed and have some understanding of the basic Linux commands and configuration file structure. We won't explain how to install Nginx here, assuming you've completed this step. remember

Navicat provides tips for batch modifying text data: use SQL statements to perform precise modifications through query generators. Simple text replacement with the help of data import/export. Edit data directly in the Data Grid view for small-scale modifications. Common pitfalls of batch modification: SQL injection risk: filtering and escaping user input. Data type mismatch: Make sure the data type matches. Transaction processing: Use transaction processing to ensure data consistency. Error handling: Use the error handling mechanism and record the error message.

When considering deleting SQL lines, you should be aware of the following: Understand how DELETE statements work and do not confuse them with TRUNCATE or DROP. Use the WHERE clause to specify exactly the rows to be deleted to avoid mistaken deletion. Use batch deletion and transactions as needed to improve efficiency and ensure data consistency. Operate with caution, back up data, and use a test environment to avoid data loss.

Adding columns at the end of a database table is not easy, the specific operation depends on the database system, table size and data volume. Common errors include: ignoring data types, incorrectly using indexes, and concurrent operations. Optimization strategies include: selecting the appropriate storage engine, using partition tables, and utilizing database replication technology. Good code readability and maintainability also help avoid problems. Only by operating with caution and paying attention to the underlying mechanism can we avoid risks in data security and integrity.
