python邮件处理(smtplib与email模块)、mql4中的邮件处理

37 篇文章 5 订阅

python:

Python SMTP发送邮件 | 菜鸟教程  http://www.runoob.com/python/python-email.html

smtplib与email模块(实现邮件的发送)https://www.cnblogs.com/freely/p/6859117.html

smtplib — SMTP protocol client — Python 3.7.1 documentation  https://docs.python.org/3.7/library/smtplib.html

python3发送邮件(有附件) - sammy1989 - 博客园  https://www.cnblogs.com/sammy1989/p/6137928.html

python发送邮件脚本(支持多个附件,中文) - RangeYan - CSDN博客  https://blog.csdn.net/yanshu2012/article/details/50396068

python邮件处理包email发邮件,邮件名称含有中文,但在接收邮箱中显示的文件名称及后缀却完全不一样。

att1["Content-Disposition"] = 'attachment; filename= "销售明细.xls"'
#邮件附件名称含有中文,收到邮件就是错误的名称,打不开。
att1["Content-Disposition"] = 'attachment; filename= "1.xls"'
#邮件名称换成英或或数字的,就正常发送邮件






email — An email and MIME handling package — Python 3.7.1 documentation  https://docs.python.org/3/library/email.html

email — An email and MIME handling package — Python 3.7.1 documentation  https://docs.python.org/3/library/email.html#module-email

email: Examples — Python 3.7.1 documentation  https://docs.python.org/3/library/email.examples.html

18.1.5. email.header: Internationalized headers — Python 2.7.15 documentation  https://docs.python.org/2/library/email.header.html

tcmime.1994.2551.9962.bin是个什么东西呢

Python 3中bytes/string的区别 - abce - 博客园  http://www.cnblogs.com/abclife/p/7445222.html

python-string和bytes的关系 - More and Better - CSDN博客  https://blog.csdn.net/qq_25730711/article/details/53817256

Python中email包的使用:


python发邮件详解,smtplib和email模块详解 - chinesepython的博客 - CSDN博客  https://blog.csdn.net/chinesepython/article/details/82465947

email:

The email package is a library for managing email messages. It is specifically not designed to do any sending of email messages to SMTP (RFC 2821), NNTP, or other servers; those are functions of modules such as smtplib and nntplib.

email包是一个管理电子邮件信息的库。它不是专门用来向SMTP,NNTP或其它服务器发送邮件信息,这些功能是smtplib包 和nntplib包的功能。

The overall structure of the email package can be divided into three major components, plus a fourth component that controls the behavior of the other components.

email包的整体结构分为三个主要组件,外加控制组件行为的第四个组件。

email模块下的mime模块下有常用的三个模块,三个模块中有三个大类。

如果构造MIMEText对象,表示文本邮件对象;如果构造MIMEImage对象,表示作为附件的图片对象;要把多个对象组合起来,就用MIMEMultipart对象,代表整个邮件。

MIMEText对象中需要设置三个参数:正文内容、正文内容的类型(例如:”text/plain”和”text/html”)、正文内容的编码。

 

 

from email.mime.text import MIMEText    
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart 

组件一:电子邮件信息的对象模型

The central component of the package is an “object model” that represents email messages. An application interacts with the package primarily through the object model interface defined in the message sub-module.

包核心组件是一个表示邮件信息的“对象模型”。应用程序主要通过信息子模块中定义的对象模型接口进行交互。

The application can use this API to ask questions about an existing email, to construct a new email, or to add or remove email subcomponents that themselves use the same object model interface.

应用程序用API来询问关于现有邮件的问题,构建一个新邮件,或者加入或者移除使用相同对象接口的email子组件。

That is, following the nature of email messages and their MIME subcomponents, the email object model is a tree structure of objects that all provide the EmailMessage API.

也就是说,根据电子邮件消息及其MIME子组件的性质,电子邮件对象模型是所有提供EmailMessage API的对象的树结构。

组件二、三:解析器、生成器

The other two major components of the package are the parser and the generator. The parser takes the serialized version of an email message (a stream of bytes) and converts it into a tree of EmailMessage objects. The generator takes an EmailMessage and turns it back into a serialized byte stream. (The parser and generator also handle streams of text characters, but this usage is discouraged as it is too easy to end up with messages that are not valid in one way or another.)

包的其他两个主要组件是解析器和生成器。解析器获取电子邮件消息的序列化版本(字节流)并将其转换为EmailMessage对象树。生成器接收电子邮件消息并将其转换回序列化的字节流。(解析器和生成器也处理文本字符流,但是这种用法是不鼓励的,因为它很容易以某种方式无效的消息结束。)

 

控制组件是策略模块

The control component is the policy module. Every EmailMessage, every generator, and every parser has an associated policy object that controls its behavior. Usually an application only needs to specify the policy when an EmailMessage is created, either by directly instantiating an EmailMessage to create a new email, or by parsing an input stream using a parser. But the policy can be changed when the message is serialized using a generator. This allows, for example, a generic email message to be parsed from disk, but to serialize it using standard SMTP settings when sending it to an email server.

每个电子邮件消息、每个生成器和每个解析器都有一个控制其行为的关联策略对象。通常,应用程序只需要在创建EmailMessage时指定策略,要么直接实例化EmailMessage来创建新电子邮件,要么使用解析器解析输入流。但是当使用生成器序列化消息时,可以更改策略。例如,这允许从磁盘解析一般的电子邮件消息,但是在将其发送到电子邮件服务器时,可以使用标准SMTP设置对其进行序列化。

 

mql4:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一些测试Python使用smtplib模块来实现Email客户端的步骤: 1. 首先,确保您已经安装了Pythonsmtplib模块,您可以使用以下命令来检查是否已安装: ``` import smtplib ``` 如果没有报错,则已安装。 2. 然后,您需要创建一个SMTP对象,以便连接到您的邮件服务器。您可以使用以下代码: ``` smtpObj = smtplib.SMTP('邮件服务器地址', 端口号) ``` 请注意,在上面的代码,您需要将“邮件服务器地址”和“端口号”替换为您的邮件服务器的实际地址和端口号。 3. 接下来,您需要使用您的邮件服务器的凭据进行身份验证。您可以使用以下代码: ``` smtpObj.login('您的用户名', '您的密码') ``` 请注意,在上面的代码,您需要将“您的用户名”和“您的密码”替换为您的邮件服务器的实际用户名和密码。 4. 然后,您可以使用以下代码发送邮件: ``` smtpObj.sendmail('发件人', '收件人', '邮件内容') ``` 请注意,在上面的代码,您需要将“发件人”、“收件人”和“邮件内容”替换为您实际的发件人、收件人和邮件内容。 5. 最后,您可以使用以下代码关闭SMTP对象: ``` smtpObj.quit() ``` 这将断开与您的邮件服务器的连接。 6. 在测试期间,您可以使用邮件服务器提供的Webmail界面来检查是否已成功发送电子邮件。如果您收到了电子邮件,则表示测试已成功。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值