1.起因:send fail SMTP AUTH extension not supported by server. 使用端口25 和587均失效出现此问题

首先前往outlook修改设置pop和IMAP开启,允许第三方调用:https://outlook.live.com/owa/?path=/options/popandimap

【在使用QQ邮箱IOS端的APP添加outlook邮箱时,显示IMAP没有开启】是否意指当您在iOS手机设备中进行配置微软帐户至第三方域名邮箱(QQ邮箱)时,

系统提示Outlook邮箱中的IMAP并未开启?

  1. 请您前往网页版Outlook邮箱的【POP和IMAP】;
  2. 接着,请您在【POP选项】选择【是】;
  3. 在【使用POP的设备和应用可以设置为删除重Outlook下载的邮件】中,我们建议您点选【不允许设备和应用删除来自Outlook的邮件。它会将邮件移动到特殊的POP文件夹】,这是为了防止您的邮件丢失的情况;
  4. 请完成以上步骤后,单击【保存】即可。

查询原因:版本使用python3.7,官网做出如下变动:server_hostname cannot be an empty string or start with a leading dot.

也就是说现在对于3.7需要对非ssl模式传入smtp server对象传入str模式的host地址再进行server对象创建连接

或者:

在github有人曾给出如下修复针对ssl,非ssl

https://github.com/tp4a/teleport/commit/dea9c48d825e7bac5bbc41006bc993713e4b516f

尝试修复:服务器不支持SMTP AUTH扩展。

最终及解决代码如下:

#!/usr/bin/python3
import os
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.header import Header
from email.mime.image import MIMEImage def main(): sender='chen1054@outlook.com'
receiverList=['chen1054@outlook.com']
user='chen1054@outlook.com'
emailPwd='youroutlookpwd'#用户邮箱密码无需开通授权码
smtpServer=r'smtp-mail.outlook.com'
commonPort=587 # 25也有效
emailTitle='Hello,World!'
htmlPath=r'F:/eclipse/readme/readme_eclipse.html'
attachPathList=[r'C:\Users\Administrator\PycharmProjects\Supro\src\logs\Info\20190330.log',r'C:\Users\Administrator\PycharmProjects\Supro\src\logs\Info\testpc.png']
emailChanel(sender,receiverList,user,emailPwd,smtpServer,commonPort,emailTitle,htmlPath,attachPathList) def emailChanel(sender,receiverList,user,emailPwd,smtpServer,commonPort,emailTitle,htmlPath=None,attachPathList=None):
multiPart=MIMEMultipart()
multiPart['From']=sender
multiPart['To']=','.join(receiverList)
subject=emailTitle
multiPart['Subject']=Header(subject,"utf-8")
if os.path.isfile(htmlPath):
if os.path.exists(htmlPath):
pass
else:
raise IOError("htmlPath not exist")
else:
raise IOError("html path is not file..")
emailBody=MIMEText(_text=open(htmlPath,'rb').read(),_subtype='html',_charset="utf-8")
multiPart.attach(emailBody)
if isinstance(attachPathList,list):
for attachPath in attachPathList:
if os.path.exists(attachPath):
pass
else:
raise IOError("attachPath not exist")
else:
raise TypeError("expected type is list,but get {}".format(type(attachPathList).__name__))
for attachPath in attachPathList:
if os.path.splitext(attachPath)[-1]==".log":
attach=MIMEText(open(attachPath, 'rb').read(), 'base64', 'utf-8')
attach["Content-Type"] = 'application/octet-stream'
attach["Content-Disposition"] = 'attachment; filename="dailyLog.log"' # filename not strict
multiPart.attach(attach)
if os.path.splitext(attachPath)[-1]==".png":
fp = open(attachPath, 'rb')
msgImage = MIMEImage(fp.read(),_subtype='octet-stream')
fp.close()
msgImage.add_header('Content-Disposition', 'attachment', filename="attach.png")
multiPart.attach(msgImage)
# https://github.com/tp4a/teleport/commit/dea9c48d825e7bac5bbc41006bc993713e4b516f
smtp=smtplib.SMTP("{}:{}".format(smtpServer,commonPort))
try:
smtp.ehlo()
smtp.starttls()
smtp.login(user,emailPwd)
smtp.sendmail(sender,receiverList,multiPart.as_string())
except smtplib.SMTPException as e:
print("send fail",e)
else:
print("success")
finally:
try:
smtp.quit()
except smtplib.SMTPException:
print("quit fail")
else:
print("quit success")
if __name__ == '__main__':
main()

  

如果你对上面问题还有疑问可以加群咨询我:

smtp outlook邮件发送非授权码模式的更多相关文章

  1. Oauth2.0认证---授权码模式

    目录: 1.功能描述 2.客户端的授权模式 3.授权模式认证流程 4.代码实现 1.功能描述 OAuth在"客户端"与"服务提供商"之间,设置了一个授权层(au ...

  2. asp.net权限认证:OWIN实现OAuth 2.0 之授权码模式(Authorization Code)

    asp.net权限认证系列 asp.net权限认证:Forms认证 asp.net权限认证:HTTP基本认证(http basic) asp.net权限认证:Windows认证 asp.net权限认证 ...

  3. OAuth 2.0之授权码模式

    转载自:http://www.ruanyifeng.com/blog/2014/05/oauth_2_0.html OAuth 2.0授权码模式 授权码模式(authorization code)是功 ...

  4. 学习Spring Security OAuth认证(一)-授权码模式

    一.环境 spring boot+spring security+idea+maven+mybatis 主要是spring security 二.依赖 <dependency> <g ...

  5. oauth2.0授权码模式详解

    授权码模式原理 授权码模式(authorization code)是功能最完整.流程最严密的授权模式.它的特点就是通过客户端的后台服务器,与"服务提供商"的认证服务器进行互动. 它 ...

  6. Spring Cloud2.0之Oauth2环境搭建(授权码模式和密码授权模式)

    oauth2 server 微服务授权中心,    github源码  https://github.com/spring-cloud/spring-cloud-security 对微服务接口做一些权 ...

  7. Oauth2认证模式之授权码模式实现

    Oauth2认证模式之授权码模式(authorization code) 本示例实现了Oauth2之授权码模式,授权码模式(authorization code)是功能最完整.流程最严密的授权模式.它 ...

  8. 微信授权就是这个原理,Spring Cloud OAuth2 授权码模式

    上一篇文章Spring Cloud OAuth2 实现单点登录介绍了使用 password 模式进行身份认证和单点登录.本篇介绍 Spring Cloud OAuth2 的另外一种授权模式-授权码模式 ...

  9. Spring Security OAuth2 Demo —— 授权码模式

    本文可以转载,但请注明出处https://www.cnblogs.com/hellxz/p/oauth2_oauthcode_pattern.html 写在前边 在文章OAuth 2.0 概念及授权流 ...

随机推荐

  1. Spring 、SpringMVC 、Struts2之间的区别

    一.Spring与SpringMVC的区别: spring是一个开源框架,是为了解决企业应用程序开发,功能如下: 功能:使用基本的JavaBean代替EJB,并提供了更多的企业应用功能 范围:任何Ja ...

  2. YII使用beanstalk队列

    转载于:http://blog.csdn.net/yao970953039/article/details/41821387 1.系统centos 我是直接使用yum install beanstal ...

  3. Github的readme.md的排版

    排版格式: 1 标题与文字格式 标题 # 这是 H1 <一级标题> ## 这是 H2 <二级标题> ###### 这是 H6 <六级标题> 文字格式 **这是文字粗 ...

  4. JavaScript 面向对象的程序设计

    面向对象(Object-oriented,OO)的语言有一个标志,那就是它们都有类的概念.而通过类可以创建任意多个具有相同属性和方法的对象.前面提到过,ECMAScript中没有类的概念,因此它的对象 ...

  5. 推荐一个 JavaScript 日期处理类库 Moment.js

    官网: http://momentjs.com/ 处理时间的展示,很方便. 安装 bower install moment --save # bower npm install moment --sa ...

  6. 精华阅读第 12 期 | 最新 App Store 审核指南与10大被拒理由?

    很多时候,我们对技术的追求是没有止境的,我们需要不断的学习,进步,再学习,再进步!本文系移动精英开发俱乐部的第12期文章推荐阅读整理,其中涉及到了 Android 数据库框架,架构设计中的循环引用,同 ...

  7. LeetCode题解之Intersection of Two Linked Lists

    1.题目描述 2.问题分析 使用unordered_set 将链表A中的节点地址全部插入,然后使用链表B中的每个节点在A中查找. 3.代码 ListNode *getIntersectionNode( ...

  8. jquery validation表单验证插件2。

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  9. [VS2008] 安装 AnkhSVN 后,选项中选择它,Pending Changes 窗口一闪而过,源代码管理工具自动跳回 【None】

    执行以下命令以修复: "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe" /re ...

  10. 【2017-11-19】Linux基础知识:TP-Link WN823N无线网卡(RTL8192EU芯片)的X86-64及AARCH64驱动安装

    目的: 使类似于树莓派的AARCH-64架构的嵌入式设备能通过USB无线网卡连接上以太网: 该设备有LAN接口,但在前一次系统固件升级后,其内部的三个网络接口可以相互ping通,但任一接口无法ping ...