iis服务器助手广告广告
返回顶部
首页 > 资讯 > 后端开发 > Python >python 发送邮件
  • 153
分享到

python 发送邮件

发送邮件python 2023-01-31 01:01:52 153人浏览 安东尼

Python 官方文档:入门教程 => 点击学习

摘要

#!/usr/bin/env python#coding:utf-8 import smtplib,time,stringfrom email.mime.text import MIMEText SMTPserver = 'smtp.exm

#!/usr/bin/env python
#coding:utf-8

import smtplib,time,string
from email.mime.text import MIMEText

SMTPserver = 'smtp.exmail.qq.com' # 腾讯企业邮箱
sender = 'xxx' # 发件人邮箱
passWord = "xxx" #发件人smtp客户端登陆密码
To = '1210577423@qq.com' # 收件人邮箱

message = string.join((
'from ', sender,
'to', To ,
'I send a message by Python hello ',
),"\r\n") # 构造邮件内容

msg = MIMEText(message)
msg['Subject'] = 'test email to python' # 邮件主题
msg['From'] = sender
msg['To'] = ' xxx ' #destination # 收件人邮箱

mailserver = smtplib.SMTP(SMTPserver,25)
mailserver.login(sender,password)
mailserver.sendmail(sender,[To],msg.as_string())
mailserver.quit()

print ' send email success '

with open('/var/log/email.log','a') as f:
date=time.strftime("%y-%m-%d %H:%M:%S")
str=date + " " + To + message + '\n'
f.write(str) # 记录邮件内容

--结束END--

本文标题: python 发送邮件

本文链接: https://www.lsjlt.com/news/183971.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • python发送邮件
    python通过smtp发送qq邮件 import smtplib from email.mime.text import MIMEText from email.header import Header """ 1》测试邮件发送 ...
    99+
    2023-01-30
    发送邮件 python
  • python 邮件发送
    环境:python2.7 1 #coding:utf-8 2 from __future__ import unicode_literals 3 __author__ = 'crista' 4 5 import smtpli...
    99+
    2023-01-30
    邮件发送 python
  • python 发送邮件
    #!/usr/bin/env python#coding:utf-8 import smtplib,time,stringfrom email.mime.text import MIMEText SMTPserver = 'smtp.exm...
    99+
    2023-01-31
    发送邮件 python
  • python发送、抄送邮件
    python发送抄送邮件 sendemial.py #!/usr/bin/python # -*- coding: UTF-8 -*- import smtplib from email.mime.text import MIMETe...
    99+
    2023-01-31
    邮件 python
  • python SMTP邮件发送
    本例使用的时python2.7环境,python3的操作应该也是差不多的。 需要用到smtplib和email两个包。 发送文本类型的邮件 下面看个发送文本邮件的例子(使用网易163的SMTP): # -*- coding: UTF-8 ...
    99+
    2023-01-31
    邮件发送 python SMTP
  • python发送邮件和附件
    发送邮件的时候,需要发送人,收件人,和一台邮件服务器,这里使用python发送一个邮件,主要需要引入smtplib和email库。下面是源码,粘贴即可用: #!/usr/bin/env python3 # coding: utf-8 imp...
    99+
    2023-01-31
    发送邮件 附件 python
  • python 发送中文邮件
    #!/usr/bin/python#coding:utf-8#导入smtplib和MIMEText import smtplibfrom email.Header import Headerfrom email.MIMEText impor...
    99+
    2023-01-31
    中文 邮件 python
  • Python实现邮件发送
    使用smtplib模块发送邮件,它对smtp协议进行了简单的封装。smtp协议的基本命令包括:    HELO 向服务器标识用户身份    MAIL 初始化邮件传输 mail from:    RCPT 标识单个的邮件接收人;常在MAIL命...
    99+
    2023-01-31
    邮件发送 Python
  • zabbix用python发送邮件
    !/usr/bin/pythoncoding: utf-8import smtplibimport sysfrom email.mime.text import MIMEText_user = "12345678@qq.com"_pwd ...
    99+
    2023-01-31
    发送邮件 zabbix python
  • Python批量发送邮件
    1.SMTP协议SMTP(Simple Mail Transfer Protocol)即简单邮件传输协议,是一个相对简单的基于文本的协议, 在其之上指定了一条消息的一个或多个接收者(在大多数情况下被确认是存在的),然后消息文本会被传输。可以...
    99+
    2023-06-02
  • python通过163邮箱发送邮件
    from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText import smtplib import sys impor...
    99+
    2023-01-31
    发送邮件 邮箱 python
  • python发送带附件的邮件
      来源:http://snipperize.todayclose.com/snippet/py/Send-email-with-p_w_upload--53762/ Send email with p_w_upload import sm...
    99+
    2023-01-31
    附件 邮件 python
  • python如何发送qq邮件
    这篇文章给大家分享的是有关python如何发送qq邮件的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。python自带了两个模块smtplib和email用于发送邮件。smtplib模块主要负责发送邮件,它对smt...
    99+
    2023-06-14
  • 使用python发送html邮件
    说明:   最近一直在忙着业务迁移工作,己经有些日子没有写东西了,虽然写的很渣,还好是将功能实现了。#!/usr/bin/env python #coding:utf8   import smtplib from email.mime.te...
    99+
    2023-01-31
    邮件 python html
  • Python 使用Gmail发送邮件
    前言:2014-05-22记录在hi baidu上,现在移过来 使用python向gmail发邮件 """ 发送邮件 1: 需要提供发送者的邮件、密码;接收者地址; 2:步骤: a:Logi...
    99+
    2023-01-31
    发送邮件 Python Gmail
  • Python 调用API发送邮件
    在运营或者对各种 SDK 或者 API 进行调试的时候,邮件功能基本上都会被使用到。 在测试的时候,可能很多人都会使用 SMTP 或者自己的邮箱使用 SMTP 来进行发送,通常来说是...
    99+
    2022-11-11
  • Python发送邮件的例子
    import smtplib from email.mime.text import MIMEText from email.header import Header # 第三方 SMTP 服务 mail_host="smtp.qq...
    99+
    2023-01-31
    发送邮件 例子 Python
  • python 发送邮件给多人
    python发送邮件相信很多python使用者都会,这里介绍针对发给多个收件人的心得:关键点1:收件人邮箱msg_to=['abc@163.com','dhsjkbsh@qq.com','123463255@qq.com'],以列表的方式...
    99+
    2023-01-31
    发送邮件 python
  • python 使用stmp发送邮件
    SMTP(Simple Mail Transfer Protocol)即简单邮件传输协议,它是一组用于由源地址到目的地址传送邮件的规则,由它来控制信件的中转方式。 python的smtplib提供了一种很方便的途径发送电子邮件。它对smtp...
    99+
    2023-01-31
    发送邮件 python stmp
  • 怎么用Python发送邮件
    本篇内容主要讲解“怎么用Python发送邮件”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“怎么用Python发送邮件”吧!Python使用SMTP发送邮件SMTP(Simple Mail Tra...
    99+
    2023-06-04
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作