用最简单方法解决api接口安全问题,几乎无法破解
docker运行gunicorn看不到控制台输出

利用qq邮箱作为个人邮件服务器发送邮件

妙音 posted @ 2019年4月06日 07:47 in python with tags 运维 , 1460 阅读
 需求描述
    邮件通知很有用处。如何搭建一个邮件服务器,允许发送邮件呢?
 

实现方法

 
一、利用开源软件,搭建自己的邮件服务器。
二、利用qq等第三方邮件服务。
 
自己搭邮件服务器较麻烦,我的需求比较简单,利用qq邮件,发送邮件即可,下面是方法.
 
 
 

设置方法

 
1.开启服务,获取授权码
邮箱设置-->帐户-->开启"IMAP/SMTP服务"
 
 
 
开启成功后,会给出一个授权码.
授权码就是发送邮件时的密码
 
2.python发送邮件
 
# -*- coding:utf-8 -*-
import smtplib
from email.mime.text import MIMEText
from email.header import Header

# 第三方 SMTP 服务
mail_host="smtp.qq.com"
mail_user="开启stmp服务器qq邮箱@qq.com"
mail_pass="授权码xxxx"   #口令/授权码


sender = 'sender@qq.com'
receivers = ['接收者@ikasinfo.com']

message = MIMEText('邮件发送测试...', 'plain', 'utf-8')
message['From'] = Header("测试", 'utf-8')
message['To'] =  Header("测试", 'utf-8')

subject = '邮件测试'
message['Subject'] = Header(subject, 'utf-8')

smtpObj = smtplib.SMTP_SSL()
smtpObj.connect(mail_host, 465)    # 465为SMTP加密端口号
smtpObj.login(mail_user,mail_pass)
smtpObj.sendmail(sender, receivers, message.as_string())
print("邮件发送成功")
 
此生必看的科学实验-水知道答案
《了凡四训》详解之改过之法
印光大师十念法(胡小林主讲第1集)
精神病为什么治不好
百病之源
 
 
Avatar_small
farhan 说:
2020年11月10日 00:48

Wow! Such an amazing and helpful post this is. I really really love it. It's so good and so awesome. I am just amazed. I hope that you continue to do your work like this in the future also. 먹튀검증

Avatar_small
먹튀검증 说:
2020年11月14日 11:11

There's lots of dissertation internet websites via the internet at the time you get unsurprisingly discussed as part of your page.

Avatar_small
the avenir 说:
2020年11月16日 10:41

I recently found many useful information in your website especially this blog page. Among the lots of comments on your articles. Thanks for sharing.

Avatar_small
farhan 说:
2020年11月17日 14:43

Positive site, where did u come up with the information on this posting? I'm pleased I discovered it though, ill be checking back soon to find out what additional posts you include. 먹튀검증커뮤니티

Avatar_small
Top SEO 说:
2020年11月24日 10:31

Really I enjoy your site with effective and useful information. It is included very nice post with a lot of our resources.thanks for share. i enjoy this post. Hemp Bud


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter