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

2024-01-04 13:58

本文主要是介绍python邮件处理(smtplib与email模块)、mql4中的邮件处理,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

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:

这篇关于python邮件处理(smtplib与email模块)、mql4中的邮件处理的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/569544

相关文章

浅析Python中的绝对导入与相对导入

《浅析Python中的绝对导入与相对导入》这篇文章主要为大家详细介绍了Python中的绝对导入与相对导入的相关知识,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录1 Imports快速介绍2 import语句的语法2.1 基本使用2.2 导入声明的样式3 绝对import和相对i

Python中配置文件的全面解析与使用

《Python中配置文件的全面解析与使用》在Python开发中,配置文件扮演着举足轻重的角色,它们允许开发者在不修改代码的情况下调整应用程序的行为,下面我们就来看看常见Python配置文件格式的使用吧... 目录一、INI配置文件二、YAML配置文件三、jsON配置文件四、TOML配置文件五、XML配置文件

Gin框架中的GET和POST表单处理的实现

《Gin框架中的GET和POST表单处理的实现》Gin框架提供了简单而强大的机制来处理GET和POST表单提交的数据,通过c.Query、c.PostForm、c.Bind和c.Request.For... 目录一、GET表单处理二、POST表单处理1. 使用c.PostForm获取表单字段:2. 绑定到结

mysql8.0无备份通过idb文件恢复数据的方法、idb文件修复和tablespace id不一致处理

《mysql8.0无备份通过idb文件恢复数据的方法、idb文件修复和tablespaceid不一致处理》文章描述了公司服务器断电后数据库故障的过程,作者通过查看错误日志、重新初始化数据目录、恢复备... 周末突然接到一位一年多没联系的妹妹打来电话,“刘哥,快来救救我”,我脑海瞬间冒出妙瓦底,电信火苲马扁.

Python中conda虚拟环境创建及使用小结

《Python中conda虚拟环境创建及使用小结》本文主要介绍了Python中conda虚拟环境创建及使用小结,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们... 目录0.前言1.Miniconda安装2.conda本地基本操作3.创建conda虚拟环境4.激活c

使用Python创建一个能够筛选文件的PDF合并工具

《使用Python创建一个能够筛选文件的PDF合并工具》这篇文章主要为大家详细介绍了如何使用Python创建一个能够筛选文件的PDF合并工具,文中的示例代码讲解详细,感兴趣的小伙伴可以了解下... 目录背景主要功能全部代码代码解析1. 初始化 wx.Frame 窗口2. 创建工具栏3. 创建布局和界面控件4

一文详解如何在Python中使用Requests库

《一文详解如何在Python中使用Requests库》:本文主要介绍如何在Python中使用Requests库的相关资料,Requests库是Python中常用的第三方库,用于简化HTTP请求的发... 目录前言1. 安装Requests库2. 发起GET请求3. 发送带有查询参数的GET请求4. 发起PO

Python与DeepSeek的深度融合实战

《Python与DeepSeek的深度融合实战》Python作为最受欢迎的编程语言之一,以其简洁易读的语法、丰富的库和广泛的应用场景,成为了无数开发者的首选,而DeepSeek,作为人工智能领域的新星... 目录一、python与DeepSeek的结合优势二、模型训练1. 数据准备2. 模型架构与参数设置3

Python进行PDF文件拆分的示例详解

《Python进行PDF文件拆分的示例详解》在日常生活中,我们常常会遇到大型的PDF文件,难以发送,将PDF拆分成多个小文件是一个实用的解决方案,下面我们就来看看如何使用Python实现PDF文件拆分... 目录使用工具将PDF按页数拆分将PDF的每一页拆分为单独的文件将PDF按指定页数拆分根据页码范围拆分

Node.js net模块的使用示例

《Node.jsnet模块的使用示例》本文主要介绍了Node.jsnet模块的使用示例,net模块支持TCP通信,处理TCP连接和数据传输,具有一定的参考价值,感兴趣的可以了解一下... 目录简介引入 net 模块核心概念TCP (传输控制协议)Socket服务器TCP 服务器创建基本服务器服务器配置选项服