Changes
This commit is contained in:
parent
bbf3a4eb6a
commit
9171ad584a
@ -8,6 +8,7 @@
|
|||||||
### 单目录 (root)
|
### 单目录 (root)
|
||||||
|名称|路径|介绍|语言|
|
|名称|路径|介绍|语言|
|
||||||
|:---|:---|----|----|
|
|:---|:---|----|----|
|
||||||
|
|README|README.md|自述文件|Markdown|
|
||||||
|LAN++|./lanpp|一个跨平台的简易局域网文件传输工具|Python|
|
|LAN++|./lanpp|一个跨平台的简易局域网文件传输工具|Python|
|
||||||
|Plane Fighting|./plane_fighting|一个跨平台的简易"飞机大战"小游戏|Python|
|
|Plane Fighting|./plane_fighting|一个跨平台的简易"飞机大战"小游戏|Python|
|
||||||
|Python HTTPS Server|./python_https_server|一个 HTTPS 网络服务器程序|Python|
|
|Python HTTPS Server|./python_https_server|一个 HTTPS 网络服务器程序|Python|
|
||||||
@ -15,6 +16,7 @@
|
|||||||
### 单文件 (onefile)
|
### 单文件 (onefile)
|
||||||
|文件名|介绍|语言|
|
|文件名|介绍|语言|
|
||||||
|----|----|----|
|
|----|----|----|
|
||||||
|
|README|README.md|自述文件|Markdown|
|
||||||
|file_reader.cpp|输出文件内容至终端|C++|
|
|file_reader.cpp|输出文件内容至终端|C++|
|
||||||
|pause.cpp|按任意键继续|C++|
|
|pause.cpp|按任意键继续|C++|
|
||||||
|fastmaillib.py|开箱即用的 Python 邮件封装|Python|
|
|fastmaillib.py|开箱即用的 Python 邮件封装|Python|
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
# fastmaillib.py
|
# fastmaillib.py
|
||||||
# LICENSE: MIT
|
# LICENSE: MIT
|
||||||
# VERSION: v0.2
|
# VERSION: v0.2.1
|
||||||
"""
|
"""
|
||||||
|
说明:
|
||||||
更加方便地使用 Python 收邮件
|
更加方便地使用 Python 收邮件
|
||||||
部分基于 Liao Xuefeng 的代码, 并进行了封装操作
|
部分基于 Liao Xuefeng 的代码, 并进行了封装操作
|
||||||
此代码为 Python 3.x 而设计, 但理论上兼容 Python 2.x(2.7)
|
此代码为 Python 3.x 而设计, 但理论上兼容 Python 2.x(2.7)
|
||||||
"""
|
"""
|
||||||
|
"""
|
||||||
|
日志:
|
||||||
|
v0.2.3:
|
||||||
|
修复 Get.get 函数中 num 参数不可用问题
|
||||||
|
"""
|
||||||
|
|
||||||
import email, smtplib
|
import email, smtplib
|
||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
@ -23,33 +29,33 @@ class Get:
|
|||||||
obj.pass_(password)
|
obj.pass_(password)
|
||||||
return obj
|
return obj
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return False
|
return e
|
||||||
def num(obj):
|
def num(obj):
|
||||||
"""Get the number of messages on hand"""
|
"""Get the number of messages on hand"""
|
||||||
try:
|
try:
|
||||||
resp, mails, octets = obj.list()
|
resp, mails, octets = obj.list()
|
||||||
return len(mails)
|
return len(mails)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return False
|
return e
|
||||||
def get(obj, num):
|
def get(obj, num):
|
||||||
"""Get mail's content"""
|
"""Get mail's content"""
|
||||||
try:
|
try:
|
||||||
resp, mails, octets = obj.list()
|
resp, mails, octets = obj.list()
|
||||||
index = len(mails)
|
index = len(mails)
|
||||||
resp, lines, octets = obj.retr(index - 1) #
|
resp, lines, octets = obj.retr(num)
|
||||||
message_content = b'\r\n'.join(lines).decode('utf-8')
|
message_content = b'\r\n'.join(lines).decode('utf-8')
|
||||||
message = Parser().parsestr(message_content)
|
message = Parser().parsestr(message_content)
|
||||||
info = Get.print_info(message)
|
info = Get.print_info(message)
|
||||||
return info
|
return info
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return False
|
return e
|
||||||
def quit(obj):
|
def quit(obj):
|
||||||
"""Break connection"""
|
"""Break connection"""
|
||||||
try:
|
try:
|
||||||
obj.quit()
|
obj.quit()
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return False
|
return e
|
||||||
def print_info(msg, indent=0):
|
def print_info(msg, indent=0):
|
||||||
"""Convert mail object to content"""
|
"""Convert mail object to content"""
|
||||||
total = {}
|
total = {}
|
||||||
@ -64,9 +70,9 @@ class Get:
|
|||||||
hdr, addr = parseaddr(value)
|
hdr, addr = parseaddr(value)
|
||||||
name = Get.decode_str(hdr)
|
name = Get.decode_str(hdr)
|
||||||
value = u'%s <%s>' % (name, addr)
|
value = u'%s <%s>' % (name, addr)
|
||||||
total["name"] = name
|
if not("name" in total):
|
||||||
total["addr"] = addr
|
total["name"] = name
|
||||||
# print(value)
|
total["addr"] = addr
|
||||||
if msg.is_multipart():
|
if msg.is_multipart():
|
||||||
parts = msg.get_payload()
|
parts = msg.get_payload()
|
||||||
for n, part in enumerate(parts):
|
for n, part in enumerate(parts):
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// file_reader.cpp
|
// file_reader.cpp
|
||||||
// LICENSE: MIT
|
// LICENSE: Nothing(do what ever you want!)
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user