python exchanglib 发送html邮件

def Email(to, content):
    urllib3.disable_warnings()
    creds = Credentials(
        username=‘algex\spsaccount‘,
        password=‘Spsaccount‘
    )
    config = Configuration(server="smtp.algex.asmpt.com", credentials=creds, auth_type=NTLM)
    account = Account(
        primary_smtp_address=‘[email protected]‘,
        credentials=creds,
        autodiscover=False,
        config=config,
        access_type=DELEGATE
    )

    m = Message(
        account=account,
        subject="Guest pass key generated",
        body=HTMLBody(content),
        to_recipients = [Mailbox(email_address=to)],
        cc_recipients = [Mailbox(email_address=cc)],
    )

    m.send()

上一篇文章:https://www.cnblogs.com/jpinsz/p/12418876.html 说到了使用smtplib来发邮件,但是用特定户口时提示535, b‘5.7.3 Authentication unsuccessful‘报错,一时无法解决

于是找到另一种办法,是用于与exchange server一起使用的,完美解决了我的问题,这里大概记录下,日后有用,嘿嘿

原文地址:https://www.cnblogs.com/jpinsz/p/12420991.html

时间: 2024-08-30 16:04:38

python exchanglib 发送html邮件的相关文章

python实现发送文本邮件

简单实现了python发送文本邮件 1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 4 # @Time : 2018/4/25 17:09 5 # @Author : zms 6 # @Site : 7 # @File : SendEmail.py 8 # @Software: PyCharm Community Edition 9 10 import time 11 from email.mime.text import MIMEText

【Python3爬虫】用Python实现发送天气预报邮件

此次的目标是爬取指定城市的天气预报信息,然后再用Python发送邮件到指定的邮箱. 一.爬取天气预报 1.首先是爬取天气预报的信息,用的网站是中国天气网,网址是http://www.weather.com.cn/static/html/weather.shtml,任意选择一个城市(比如武汉),然后要爬取的内容为下面的部分: 先查看网页源代码,并没有找到第一张图中的内容,说明是这些天气信息是通过别的方式加载出来的.我们打开开发者工具,点击XHR选项,发现没有任何内容,但是点击JS选项后可以找到如下

python脚本发送报警邮件

最近在搞把nagios报警邮箱换到163.sina这种免费邮箱上边,之前用过msmtp搞过也可以发送邮件,现在估计是他们系统都升级了,只能使用TSL加密连接,而msmtp怎么配置都配不通,无奈只能转移战术,正好最近在学习Python,也不知道从哪瞄到过有个email的模块,所以准备试试自己搞个脚本. (新手,无编程基础,希望多多指教) -----2016.1.4 修改---- 前提: 更改nagios/etc/object/command.cfg里发送邮件的command配置,例如我这样: # 

使用python发送QQ邮件

这里用到了Python的两个包来发送邮件: smtplib 和 email . Python 的 email 模块里包含了许多实用的邮件格式设置函数,可以用来创建邮件“包裹”.使用的 MIMEText 对象,为底层的 MIME(Multipurpose Internet MailExtensions,多用途互联网邮件扩展类型)协议传输创建了一封空邮件,最后通过高层的SMTP 协议发送出去. MIMEText 对象 msg 包括收发邮箱地址.邮件正文和主题,Python 通过它就可以创建一封格式正

python学习笔记[3]-邮件的发送

本文摘抄自:http://www.cnblogs.com/xiaowuyi/archive/2012/03/17/2404015.html 一.相关模块介绍 发送邮件主要用到了smtplib和email两个模块,这里首先就两个模块进行一下简单的介绍:    1.smtplib模块 smtplib.SMTP([host[, port[, local_hostname[, timeout]]]])   SMTP类构造函数,表示与SMTP服务器之间的连接,通过这个连接可以向smtp服务器发送指令,执行

python 发送html邮件

简单的python发送html邮件代码,如下: #!/usr/bin/env python #-*- coding:utf-8 -*- import smtplib from email.header import Header from email.MIMEText import MIMEText from email.mime.multipart import MIMEMultipart ####################################################

python 发送邮件(收到的邮件要有发送方才能回复)

Python使用SMTP(简单邮件传输协议)发送邮件 普通文本邮件 普通文本邮件发送的实现,关键是要将MIMEText中_subtype设置为plain ## -*- coding: UTF-8 -*- import smtplib from email.mime.text import MIMEText#导入MIMEText类 from email import encoders from email.header import Header from email.utils import p

python脚本连续发送QQ邮件

今天习得用python写一个连续发送QQ邮件的脚本,经过测试,成功给国内外的服务器发送邮件,包括QQ邮箱.163邮箱.google邮箱,香港科技大学的邮箱和爱丁堡大学的邮箱.一下逐步解答相关技巧. 首先,执行如下操作,__init__ 标志该文件夹是一个python程序包 $mkdir automail $cd automail $gedit qqmail $touch __init__ 打开 qqmail ,写入如下代码. 1 #-*- coding: utf -8 -*- 2 import

python 发送qq邮件

# coding=utf-8import smtplibfrom email.mime.text import MIMETextimport email def sen(file_new): msg_from = '[email protected]' # 发送方邮箱 passwd = 'xthwzlXXX' # 填入发送方邮箱的授权码 msg_to = '[email protected]' # 收件人邮箱 subject = "python邮件测试" # 主题 content =