id: bc03715348b54480b7b5f3801360720a
parent_id: 
item_type: 1
item_id: 00a8c38b4b194ed698063a89272a757b
item_updated_time: 1764345482717
title_diff: "[{\"diffs\":[[1,\"Zmail--让邮件变得简单(python)\"]],\"start1\":0,\"start2\":0,\"length1\":0,\"length2\":22}]"
body_diff: "[{\"diffs\":[[1,\"<html>\\\r\\\n<head>\\\r\\\n  <title>Zmail--让邮件变得简单(python)</title>\\\r\\\n  <basefont face=\\\"微软雅黑\\\" size=\\\"2\\\" />\\\r\\\n  <meta http-equiv=\\\"Content-Type\\\" content=\\\"text/html;charset=utf-8\\\" />\\\r\\\n  <meta name=\\\"exporter-version\\\" content=\\\"YXBJ Windows/608924 (zh-CN, DDL); Windows/10.0.0 (Win64); EDAMVersion=V2;\\\"/>\\\r\\\n  <style>\\\r\\\n\\tbody, td {\\\r\\\n\\t  font-family: 微软雅黑;\\\r\\\n\\t  font-size: 12pt;\\\r\\\n\\t}\\\r\\\n  </style>\\\r\\\n</head>\\\r\\\n<body>\\\r\\\n<a name=\\\"18327\\\"></a>\\\r\\\n<h1>Zmail--让邮件变得简单(python)</h1>\\\r\\\n\\\r\\\n<div><span>\\\n  <div style=\\\"--en-clipped-content:simplified\\\">\\\n<div><br/></div><div style=\\\"font-size: 16px; display:block; min-width: 100%;\\\"> <div style=\\\"background-color:transparent;font:inherit;vertical-align:baseline;\\\"><div style=\\\"background-color:transparent;font:inherit;vertical-align:baseline;font-family:&quot;PT Serif&quot;;font-size:16px;line-height:1.5em;color:rgb(31, 9, 9);text-align:left;\\\"><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;\\\"><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;z-index:200;padding-left:2em;padding-right:2em;margin-left:auto;margin-right:auto;position:relative;width:36em;\\\"><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;position:relative;margin-left:-25px;margin-right:25px;\\\"><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;position:relative;padding-top:0px;padding-bottom:9em;\\\"><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\"><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;position:relative;margin-bottom:0px;\\\"><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\"><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\"><h1 style=\\\"border:0px;font:inherit;vertical-align:baseline;font-family:&quot;PT Serif&quot;;text-align:left;font-size:35px;font-weight:normal;line-height:35px;margin-bottom:20px;padding:0px;margin:0px;\\\">Zmail--让邮件变得简单(python)</h1><div style=\\\"padding:0px;border:0px;font:inherit;vertical-align:baseline;position:relative;height:1em;line-height:1;text-align:center;margin:0px;padding-top:1.5em;padding-bottom:1.5em;margin-bottom:0px;\\\"><div style=\\\"padding:0px;border:0px;font:inherit;vertical-align:baseline;position:absolute;left:-4em;top:50%;z-index:10;width:100%;padding-left:4em;padding-right:4em;height:0.1em;opacity:0.5;margin:0px;background:-webkit-linear-gradient(0deg, rgb(243, 242, 238) 1%, rgb(31, 9, 9) 50%, rgb(243, 242, 238) 99%);margin-bottom:0px;\\\"><span style=\\\"font:inherit;position:absolute;left:-4em;top:50%;z-index:10;width:100%;padding-left:4em;padding-right:4em;height:0.1em;margin:0px;opacity:0.5;background:-webkit-linear-gradient(0deg, rgb(243, 242, 238) 1%, rgb(31, 9, 9) 50%, rgb(243, 242, 238) 99%);\\\"></span></div></div></div><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\"><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\"><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\"><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\"><span style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;\\\"><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\"><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\"><a href=\\\"https://www.zhihu.com/people/zhang-yun-hao-14\\\" style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(6, 85, 136);text-decoration:none;\\\" target=\\\"_blank\\\">ZYunH</a></div></div></span></div><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\"><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\"><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\">https://github.com/ZYunH</div></div></div></div></div></div><p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\">发送邮件是个很简单的需求，但是在实际的使用中依然碰到了很多坑，因此创建了zmail这个项目，让你使用python发送邮件的过程尽可能简单。</p><h2 style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:&quot;PT Serif&quot;;text-align:left;font-weight:bold;font-size:30px;line-height:35px;margin-top:35px;margin-bottom:15px;\\\">GitHub地址：<a href=\\\"https://link.zhihu.com/?target=https%3A//github.com/ZYunH/zmail\\\" style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(31, 9, 9);text-decoration:none;\\\" target=\\\"_blank\\\">https://github.com/ZYunH/zmail</a> ，觉得ok请star或者fork!!!</h2><h2 style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:&quot;PT Serif&quot;;text-align:left;font-weight:bold;font-size:30px;line-height:35px;margin-top:35px;margin-bottom:15px;\\\">其他轮子的缺点：</h2><ul style=\\\"padding:0px;border:0px;font:inherit;vertical-align:baseline;margin:0px 0px 1.5em 1.5em;list-style:none;margin-top:-1em;list-style-type:disc;\\\"><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">服务端拒信：首要问题。很多其他的轮子需要自己构造MIME和邮件头（通常优化了过程），但经常遭遇拒信，具体原因是其没有正确的定义邮件头，诸如From和To的头信息在使用SMTP时每家服务商检查都会有细微的差别，以及一些平台的差异（win10 localhost乱码导致发件拒信），甚至在你发往不同的地址检查也会有差别（国内发国外需要额外验证一些信息预防垃圾邮件）。</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">构造太麻烦：特别是添加附件的时候，有些还需要额外去自定义类型，体验很差。</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">发送太麻烦：你需要找到你服务商的smtp地址，端口号，有些服务商不是默认的端口（@<a href=\\\"https://link.zhihu.com/?target=http%3A//163.com\\\" style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(6, 85, 136);text-decoration:none;\\\" target=\\\"_blank\\\">http://163.com</a>），有些只能SSL验证（@<a href=\\\"https://link.zhihu.com/?target=http%3A//qq.com\\\" style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(6, 85, 136);text-decoration:none;\\\" target=\\\"_blank\\\">http://qq.com</a>），有些需要TLS(@gmailcom)，一个不小心就发送失败。</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">解析邮件复杂：Bytes坑多，还有boundary，各种格式乱码错误</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">引入过多的外部包：一些轮子引入了好几个包，可能会造成包与原来的程序版本冲突（常见于requests之类的包），并且发生错误无法得到及时的文档支持。在我尝试发送失败后，使用django的email模块成功发送了邮件，但是django的目的显然不是这个，使用一个如此大的框架来实现那么小的需求显然不合理（并且构造过程依然复杂）。</li></ul><h2 style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:&quot;PT Serif&quot;;text-align:left;font-weight:bold;font-size:30px;line-height:35px;margin-top:35px;margin-bottom:15px;\\\">Zmail的优势：</h2><ul style=\\\"padding:0px;border:0px;font:inherit;vertical-align:baseline;margin:0px 0px 1.5em 1.5em;list-style:none;margin-top:-1em;list-style-type:disc;\\\"><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">自动填充大多数导致服务端拒信的头信息（From To LocalHost之类的)</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">将一个字典映射为email，构造信件就像构造字典一样简单</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">自动寻找邮件服务商端口号地址，自动选择合适的协议（经过认证的）</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">只依赖于python3，嵌入其他项目时无需烦恼</li></ul><h2 style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:&quot;PT Serif&quot;;text-align:left;font-weight:bold;font-size:30px;line-height:35px;margin-top:35px;margin-bottom:15px;\\\">你可以使用zmail来：</h2><ul style=\\\"padding:0px;border:0px;font:inherit;vertical-align:baseline;margin:0px 0px 1.5em 1.5em;list-style:none;margin-top:-1em;list-style-type:disc;\\\"><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">作为监控脚本的发送&amp;接收邮件模块，及时传递信息</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">嵌入到已有的项目中实现邮件功能</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">自定义邮件发送过程，诸如准点发送、定时发送、自动监控等</li></ul><h2 style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:&quot;PT Serif&quot;;text-align:left;font-weight:bold;font-size:30px;line-height:35px;margin-top:35px;margin-bottom:15px;\\\">安装</h2><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\"><pre style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;background-color:rgb(243, 242, 238);font-family:Inconsolata;width:auto;font-size:0.875em;line-height:1.71429em;\\\"><code style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:Inconsolata;line-height:1.71429em;font-size:1.15em;\\\">$ pip3 install zmail</code></pre></div><p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\">也可以使用pip代替pip3</p><p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\">注意：zmail仅支持python3，<b style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">不支持python2</b></p><p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\"><b style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">使用前注意，所有邮箱都要开启SMTP功能，@<a href=\\\"https://link.zhihu.com/?target=http%3A//163.com\\\" style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(6, 85, 136);text-decoration:none;\\\" target=\\\"_blank\\\">http://163.com</a>和@<a href=\\\"https://link.zhihu.com/?target=http%3A//gmail.com\\\" style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;color:rgb(6, 85, 136);text-decoration:none;\\\" target=\\\"_blank\\\">http://gmail.com</a> 的邮箱需要额外设定SMTP密码，网上很多信息，具体自行百度google，这里先行省略。</b></p><h2 style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:&quot;PT Serif&quot;;text-align:left;font-weight:bold;font-size:30px;line-height:35px;margin-top:35px;margin-bottom:15px;\\\">发送邮件</h2><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\"><pre style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;background-color:rgb(243, 242, 238);font-family:Inconsolata;width:auto;font-size:0.875em;line-height:1.71429em;\\\"><code style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:Inconsolata;line-height:1.71429em;font-size:1.15em;\\\">import zmail\\\n# 你的邮件内容\\\nmail_content = {\\\n    'subject': 'Success!',  # 随便填写\\\n    'content_text': 'This message from zmail!',  # 随便填写\\\n}\\\n\\\n# 使用你的邮件账户名和密码登录服务器\\\nserver = zmail.server('12345678@qq.com, '你的qq邮箱密码')\\\n# 发送邮件\\\nserver.send_mail('555555@qq.com', mail)</code></pre></div><ul style=\\\"padding:0px;border:0px;font:inherit;vertical-align:baseline;margin:0px 0px 1.5em 1.5em;list-style:none;list-style-type:disc;\\\"><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">为你的邮件添加附件，修改 <b style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">你的邮件内容</b> 即可，其他内容同上</li></ul><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\"><pre style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;background-color:rgb(243, 242, 238);font-family:Inconsolata;width:auto;font-size:0.875em;line-height:1.71429em;\\\"><code style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:Inconsolata;line-height:1.71429em;font-size:1.15em;\\\"># 你的邮件内容\\\nmail_content = {\\\n    'subject': 'Success!',  # 随便填写\\\n    'content_text': 'This message from zmail!',  # 随便填写\\\n    'attachments': '/Users/zyh/Documents/example.zip',  # 最好使用绝对路径，若你电脑没有这个文件会造成错误\\\n}</code></pre></div><ul style=\\\"padding:0px;border:0px;font:inherit;vertical-align:baseline;margin:0px 0px 1.5em 1.5em;list-style:none;list-style-type:disc;\\\"><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">给多个信箱发件，修改 <b style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">发送邮件</b> 即可，其他内容同上</li></ul><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\"><pre style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;background-color:rgb(243, 242, 238);font-family:Inconsolata;width:auto;font-size:0.875em;line-height:1.71429em;\\\"><code style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:Inconsolata;line-height:1.71429em;font-size:1.15em;\\\"># 发送邮件\\\nserver.send_mail(['555555@qq.com','666666@qq.com'], mail)</code></pre></div><ul style=\\\"padding:0px;border:0px;font:inherit;vertical-align:baseline;margin:0px 0px 1.5em 1.5em;list-style:none;list-style-type:disc;\\\"><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">添加额外的头信息，直接加入到mail_content即可</li></ul><h2 style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:&quot;PT Serif&quot;;text-align:left;font-weight:bold;font-size:30px;line-height:35px;margin-top:35px;margin-bottom:15px;\\\"><b style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">取回你的邮件</b></h2><ul style=\\\"padding:0px;border:0px;font:inherit;vertical-align:baseline;margin:0px 0px 1.5em 1.5em;list-style:none;margin-top:-1em;list-style-type:disc;\\\"><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\"><b style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">取得最新的邮件</b></li></ul><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\"><pre style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;background-color:rgb(243, 242, 238);font-family:Inconsolata;width:auto;font-size:0.875em;line-height:1.71429em;\\\"><code style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:Inconsolata;line-height:1.71429em;font-size:1.15em;\\\">import zmail\\\nserver = zmail.server('yourmail@example.com, 'yourpassword')mail = server.get_latest()</code></pre></div><ul style=\\\"padding:0px;border:0px;font:inherit;vertical-align:baseline;margin:0px 0px 1.5em 1.5em;list-style:none;list-style-type:disc;\\\"><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\"><b style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">依据id取回邮件</b></li></ul><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\"><pre style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;background-color:rgb(243, 242, 238);font-family:Inconsolata;width:auto;font-size:0.875em;line-height:1.71429em;\\\"><code style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:Inconsolata;line-height:1.71429em;font-size:1.15em;\\\">mail = server.get_mail(2)</code></pre></div><ul style=\\\"padding:0px;border:0px;font:inherit;vertical-align:baseline;margin:0px 0px 1.5em 1.5em;list-style:none;list-style-type:disc;\\\"><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\"><b style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">依据 (subject,after,before,sender)取回一个列表的邮件</b></li></ul><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\"><pre style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;background-color:rgb(243, 242, 238);font-family:Inconsolata;width:auto;font-size:0.875em;line-height:1.71429em;\\\"><code style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:Inconsolata;line-height:1.71429em;font-size:1.15em;\\\">mail = server.get_mails(subject='GitHub',after='2018-1-1',sender='github')</code></pre></div><p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\">示例中， 如果 'GitHub' 在邮件的主题中，这封邮件将会被匹配, 例如'  [GitHub] Your password has changed'</p><p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\">sender亦是如此</p><ul style=\\\"padding:0px;border:0px;font:inherit;vertical-align:baseline;margin:0px 0px 1.5em 1.5em;list-style:none;margin-top:-1em;list-style-type:disc;\\\"><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\"><b style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">得到所有邮件的头文件信息.一个由字典组成的列表,每个字典包含了所有能够提取的头文件.</b></li></ul><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\"><pre style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;background-color:rgb(243, 242, 238);font-family:Inconsolata;width:auto;font-size:0.875em;line-height:1.71429em;\\\"><code style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:Inconsolata;line-height:1.71429em;font-size:1.15em;\\\">mail_info = server.get_info()</code></pre></div><ul style=\\\"padding:0px;border:0px;font:inherit;vertical-align:baseline;margin:0px 0px 1.5em 1.5em;list-style:none;list-style-type:disc;\\\"><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\"><b style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">得到邮箱的信息</b></li></ul><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\"><pre style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;background-color:rgb(243, 242, 238);font-family:Inconsolata;width:auto;font-size:0.875em;line-height:1.71429em;\\\"><code style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:Inconsolata;line-height:1.71429em;font-size:1.15em;\\\">mailbox_info = server.stat()</code></pre></div><p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\">结果为包含两个整型的元组: <code style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:Inconsolata;font-size:0.875em;line-height:1.71429em;\\\">(邮件的数量, 邮箱的大小)</code>.</p><h2 style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:&quot;PT Serif&quot;;text-align:left;font-weight:bold;font-size:30px;line-height:35px;margin-top:35px;margin-bottom:15px;\\\"><b style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">解析你的邮件</b></h2><p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\">在zmail中，接收到的邮件被映射为一个字典，你可以通过访问python字典的形式来访问你的邮件，字典中的所有key在下方邮件结构中有列出，例如</p><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\"><pre style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;background-color:rgb(243, 242, 238);font-family:Inconsolata;width:auto;font-size:0.875em;line-height:1.71429em;\\\"><code style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:Inconsolata;line-height:1.71429em;font-size:1.15em;\\\">subject = mail['subject']</code></pre></div><p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\">展示你的邮件，使用 <b style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">zmail.show()</b></p><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\"><pre style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;background-color:rgb(243, 242, 238);font-family:Inconsolata;width:auto;font-size:0.875em;line-height:1.71429em;\\\"><code style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:Inconsolata;line-height:1.71429em;font-size:1.15em;\\\">import zmail\\\nserver = zmail.server('yourmail@example.com, 'yourpassword')\\\nmail = server.get_latest()\\\nzmail.show(mail)</code></pre></div><p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\">输出 :</p><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\"><pre style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;background-color:rgb(243, 242, 238);font-family:Inconsolata;width:auto;font-size:0.875em;line-height:1.71429em;\\\"><code style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:Inconsolata;line-height:1.71429em;font-size:1.15em;\\\">content-type multipart/mixed\\\nsubject Success!\\\nto zmail_user\\\nfrom zmail&lt;zmail@126.com&gt;\\\ndate 2018-2-3 01:42:29 +0800\\\nboundary ===============9196441298519098157==\\\ncontent ['This message from zmail!']\\\ncontents [[b'Content-Type: text/plain; charset=&quot;utf-8&quot;', b'MIME-Version: 1.0', b'Content-Transfer-Encoding: base64', b'', b'VGhpcyBtZXNzYWdlIGZyb20gem1haWwh', b'']]\\\nattachments None\\\nid 5</code></pre></div><h2 style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:&quot;PT Serif&quot;;text-align:left;font-weight:bold;font-size:30px;line-height:35px;margin-top:35px;margin-bottom:15px;\\\"><b style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">邮件的结构</b></h2><ul style=\\\"padding:0px;border:0px;font:inherit;vertical-align:baseline;margin:0px 0px 1.5em 1.5em;list-style:none;margin-top:-1em;list-style-type:disc;\\\"><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">content-type: 邮件内容的类型</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">subject: 邮件主题</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">to：收件人</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">from：寄件人</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">date: 年-月-日 时间 时区</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">boundary: 如果邮件为multiple parts，你可以得到其分界线</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">content: 邮件的文本内容（仅在text/plain时可以被解析）</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">contents: 邮件的body,里面包含着由分界线分割的每一个段落</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">attachments: None 或者 [['附件名称;编码方式','附件的二进制内容']...]</li><li style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;list-style-type:inherit;list-style-position:outside;\\\">id: 在邮箱中的id</li></ul><h2 style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:&quot;PT Serif&quot;;text-align:left;font-weight:bold;font-size:30px;line-height:35px;margin-top:35px;margin-bottom:15px;\\\"><b style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">获得附件</b></h2><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\"><pre style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;background-color:rgb(243, 242, 238);font-family:Inconsolata;width:auto;font-size:0.875em;line-height:1.71429em;\\\"><code style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:Inconsolata;line-height:1.71429em;font-size:1.15em;\\\">import zmail\\\nserver = zmail.server('yourmail@example.com, 'yourpassword')\\\nmail = server.get_latest()\\\nzmail.get_attachment(mail)</code></pre></div><p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\">你可以重命名你的附件，使用</p><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\"><pre style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;background-color:rgb(243, 242, 238);font-family:Inconsolata;width:auto;font-size:0.875em;line-height:1.71429em;\\\"><code style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:Inconsolata;line-height:1.71429em;font-size:1.15em;\\\">zmail.get_attachment(mail,'example.zip')</code></pre></div><h2 style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-family:&quot;PT Serif&quot;;text-align:left;font-weight:bold;font-size:30px;line-height:35px;margin-top:35px;margin-bottom:15px;\\\"><b style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">支持的邮件服务商</b></h2><p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\">列表中的邮件服务商已经被测试可正常使用</p><p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;\\\"><b style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;font-weight:bold;\\\">如果你的邮箱不在此列，请不要担心，目前尚未发现不支持的邮箱.如果你发现任何问题，请在GitHub上告知于我</b> </p><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;display:block;margin-bottom:1em;margin-top:1em;\\\"><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;display:block;text-align:center;margin-top:1em;margin-bottom:0px;\\\"><img src=\\\":/84d7b0f43ddd49a3a534834b799f583e\\\" type=\\\"image/jpeg\\\" data-filename=\\\"v2-c71b0edd15300c51ce49a742495b75f4_r.jpg\\\" height=\\\"222\\\" style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;border-color:rgb(31, 9, 9);display:block;max-width:100%;\\\" width=\\\"576\\\"/></div></div><p style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:0px;\\\">更多内容请前往Github的ReadMe</p></div></div></div><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;margin-bottom:1.5em;position:absolute;top:-1000px;left:-1000px;\\\">Measure</div><div style=\\\"margin:0px;padding:0px;border:0px;font:inherit;vertical-align:baseline;position:absolute;top:-1000px;left:-1000px;line-height:1;margin-bottom:0px;\\\">Measure</div></div></div></div></div></div></div></div>\\\n</div>\\\n</span>\\\n</div></body></html>\\u0000\"]],\"start1\":0,\"start2\":0,\"length1\":0,\"length2\":27866}]"
metadata_diff: {"new":{"id":"00a8c38b4b194ed698063a89272a757b","parent_id":"061de1401cfc4cfaadf6e74e015970e9","latitude":"0.00000000","longitude":"0.00000000","altitude":"0.0000","author":"","source_url":"","is_todo":0,"todo_due":0,"todo_completed":0,"source":"joplin-desktop","source_application":"net.cozic.joplin-desktop","application_data":"","order":1764345774209,"markup_language":2,"is_shared":0,"share_id":"","conflict_original_id":"","master_key_id":"","user_data":"","deleted_time":0},"deleted":[]}
encryption_cipher_text: 
encryption_applied: 0
updated_time: 2025-11-28T16:13:03.511Z
created_time: 2025-11-28T16:13:03.511Z
type_: 13