from flask_mail import Mail,Message
from flask import Flask
import os app=Flask(__name__)
app.config.update(
DEBUG = True,
MAIL_SERVER='smtp.qq.com',
MAIL_PROT=25,
MAIL_USE_TLS = True,
MAIL_USE_SSL = False,
MAIL_USERNAME = '4@qq.com',
MAIL_PASSWORD = 'xxxxxxxx',
#MAIL_PASSWORD = 'xxxxxxxx',
MAIL_DEBUG = True
)
mail=Mail(app) @app.route('/')
def index():
# sender 发送方哈,recipients 邮件接收方列表
msg = Message("Hi!This is a test ",sender='4@qq.com', recipients=['3@qq.com'])
# msg.body 邮件正文
msg.body = "This is a first email"
# msg.attach 邮件附件添加
# msg.attach("文件名", "类型", 读取文件)
# with app.open_resource("F:\2281393651481.jpg") as fp:
# msg.attach("image.jpg", "image/jpg", fp.read()) mail.send(msg)
print ("OK")
return "Sent" if __name__=='__main__':
app.run(debug=True)

发送一直失败,查网上比较靠谱的方法参考两篇文章

http://blog.csdn.net/huochen1994/article/details/51282093

http://tieba.baidu.com/p/3870714637   这个帖子的最后一答

flask-mail发送邮件始终失败的更多相关文章

  1. java mail(发送邮件--163邮箱)

    package com.util.mail; /** * 发送邮件需要使用的基本信息 */ import java.util.Properties; public class MailSenderIn ...

  2. linux 下 用phpmailer类smtp发送邮件始终不成功,提示:ERROR: Failed to co

    https://zhidao.baidu.com/question/509191264.html?fr=iks&word=PHPMailerSMTP+connect()+failed& ...

  3. Spring Boot 揭秘与实战(七) 实用技术篇 - Java Mail 发送邮件

    文章目录 1. Spring Boot 集成 Java Mail 2. 单元测试 3. 源代码 Spring 对 Java Mail 有很好的支持.因此,Spring Boot 也提供了自动配置的支持 ...

  4. 利用System.Net.Mail 发送邮件

    我这里只是试了一下发mail的功能,感觉.net自带的发mail是比较全的,还是直接上我的code 参数文章:System.Net.Mail 发送邮件 SMTP协议 using System; usi ...

  5. Android Java Mail与Apache Mail发送邮件对比

    原文链接: 一.邮件简介  一封邮件由很多信息构成,主要的信息如下,其他的暂时不考虑,例如抄送等:  1.收件人:收件人的邮箱地址,例如xxx@xx.com  2.收件人姓名:大部分的邮件显示时都会显 ...

  6. linux下使用自带mail发送邮件

    linux下使用自带mail发送邮件 mailx工具说明: linux可以通过安装mailx工具,mailx是一个小型的邮件发送程序,一般可以通过该程序在linux系统上,进行监控linux系统状态并 ...

  7. .net System.Web.Mail发送邮件 (设置发件人 只显示用户名)

    http://blog.163.com/hao_2468/blog/static/130881568201141251642215/ .net System.Web.Mail发送邮件 2011-05- ...

  8. SpringBoot整合Mail发送邮件&发送模板邮件

    整合mail发送邮件,其实就是通过代码来操作发送邮件的步骤,编辑收件人.邮件内容.邮件附件等等.通过邮件可以拓展出短信验证码.消息通知等业务. 一.pom文件引入依赖 <dependency&g ...

  9. 使用Javax.mail 发送邮件

    使用Javax.mail 发送邮件 详细说明都在代码中: 引入依赖  <!--sun定义的一套接收.发送电子邮件的API-->    <dependency>      < ...

随机推荐

  1. 【BZOJ 4199】 [Noi2015]品酒大会

    [链接]h在这里写链接 [题意]     给你一个长度为n的字符串s;     标志了每一杯酒;     以及n个数字,表示每一杯酒的美味度ai.     两杯酒(i,j)称为r相似     当且仅当 ...

  2. VS2012 打包部署程序

      一. 下载 InstallShield 2015(支持VS2012) VS2012没有自带打包工具,所以要先下载并安装一个打包工具.我采用微软提供的打包工具:  InstallShield2015 ...

  3. [Nuxt] Navigate with nuxt-link and Customize isClient Behavior in Nuxt and Vue.js

    Because Nuxt renders pages on the server, you should use the nuxt-link components to navigate betwee ...

  4. [Node] Setup an Nginx Proxy for a Node.js App

    Learn how to setup an Nginx proxy server that sits in front of a Node.js app. You can use a proxy to ...

  5. PHP通用非法字符检测函数集锦

    <? // [变量定义规则]:‘C_’=字符型,‘I_’=整型,‘N_’=数字型,‘L_’=布尔型,‘A_’=数组型 // ※CheckMoney($C_Money) 检查数据是否是 99999 ...

  6. swift学习第十四天:属性监听器

    监听属性的改变 在OC中我们可以重写set方法来监听属性的改变 Swift中可以通过属性观察者来监听和响应属性值的变化 通常是监听存储属性和类属性的改变.(对于计算属性,我们不需要定义属性观察者,因为 ...

  7. 在vue中使用nprogress

    NProgress的官网:http://ricostacruz.com/nprogress/        源码地址:https://github.com/rstacruz/nprogress 1.安 ...

  8. JavaScript对象的创建

    原文 简书原文:https://www.jianshu.com/p/6cb1e7b7e379 大纲 前言 1.简单方式创建对象的方法 2.工厂模式创建对象 3.构造函数模式创建对象 4.原型模式创建对 ...

  9. angular2的编译模式之AOT和JIT

    原文 https://www.jianshu.com/p/c959d90e91ce 大纲 1.angular应用为什么需要编译 2.angular的编译模式类型 3.JIT(Just-In-Time) ...

  10. 【15.07%】【codeforces 625A】Guest From the Past

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...