rfc1563.The text enriched MIME Content-type

合集下载

Fiddlerresult对照

Fiddlerresult对照

100 - 表示已收到请求的一部分,正在继续发送余下部分。

101 - 切换协议。

2xx - 成功服务器成功地接受了客户端请求。

200 - 确定。

客户端请求已成功。

201 - 已创建。

202 - 已接受。

203 - 非权威性信息。

204 - 无内容。

205 - 重置内容。

206 - 部分内容。

300 - 针对收到请求,服务器可执行多种操作。

301 - 永久移动转移,请求的内容已永久移动其他新位置。

302 - 临时移动转移,请求的内容已临时移动新的位置304 - 未修改。

自从上次请求后,请求的内容未修改过。

307 - 临时重定向。

服务器目前从不同位置响应请求,但请求者应继续使用原有位置来进行以后的请求。

400 - 错误的请求。

401 - 访问被拒绝。

IIS 定义了许多不同的 401 错误,它们指明更为具体的错误原因。

这些具体的错误代码在浏览器中显示,但不在 IIS 日志中显示:401.1 - 登录失败。

401.2 - 服务器配置导致登录失败。

401.3 - 由于 ACL 对资源的限制而未获得授权。

401.4 - 筛选器授权失败。

401.5 - ISAPI/CGI 应用程序授权失败。

401.7 - 访问被 Web 服务器上的 URL 授权策略拒绝。

这个错误代码为 IIS 6.0 所专用。

403 - 禁止访问:IIS 定义了许多不同的 403 错误,它们指明更为具体的错误原因:403.1 - 执行访问被禁止。

403.2 - 读访问被禁止。

403.3 - 写访问被禁止。

403.4 - 要求 SSL.403.5 - 要求 SSL 128.403.6 - IP 地址被拒绝。

403.7 - 要求客户端证书。

403.8 - 站点访问被拒绝。

403.9 - 用户数过多。

403.10 - 配置无效。

403.11 - 密码更改。

403.12 - 拒绝访问映射表。

403.13 - 客户端证书被吊销。

403.14 - 拒绝目录列表。

MIME协议多用途互联网邮件扩展的标准

MIME协议多用途互联网邮件扩展的标准

MIME协议多用途互联网邮件扩展的标准MIME(Multipurpose Internet Mail Extensions)即多用途互联网邮件扩展,是一种应用于电子邮件的标准协议。

它的主要作用是扩展了传统的纯文本邮件,使电子邮件可以携带更多类型的数据,包括图像、音频、视频等文件格式。

本文将介绍MIME协议的起源、工作原理以及对互联网邮件系统的影响。

一、MIME协议的起源MIME协议最早由Nathaniel Borenstein和Ned Freed于1992年提出,目的是解决传统纯文本邮件无法携带多媒体文件的问题。

在起初的互联网时代,电子邮件只能发送纯文本内容,无法传输图片、音频和视频等媒体文件。

随着互联网的发展,人们对邮件内容的需求逐渐增加,MIME协议应运而生。

二、MIME协议的工作原理MIME协议通过在邮件头部添加额外的信息来标识邮件的内容类型和编码方式。

这些额外的信息被称为MIME头部信息,通常包括Content-Type、Content-Transfer-Encoding和Content-Disposition等字段。

其中,Content-Type用于指示邮件主体的数据类型,Content-Transfer-Encoding用于指定编码方式,而Content-Disposition则用于指定邮件主体的呈现方式。

MIME协议允许邮件主体以纯文本和HTML格式呈现,并支持多种文件类型的附件。

对于非文本文件,MIME协议会将它们编码成纯文本格式,以便在电子邮件传输过程中不会出现乱码或错误。

接收方的电子邮件客户端会根据MIME头部信息解析邮件内容,并以对应的方式展示给用户。

三、MIME协议对互联网邮件系统的影响MIME协议的引入极大地扩展了电子邮件的功能和应用场景。

通过MIME协议,用户可以通过邮件发送和接收各种类型的文件,如照片、音频文件和视频文件等。

这不仅提升了邮件的表现力,也方便了用户之间的信息交流。

python实现批量探测IP存活性并发送邮件告警

python实现批量探测IP存活性并发送邮件告警

python实现批量探测IP存活性并发送邮件告警在Python中,我们可以使用`ping`命令来检测IP地址的存活性,然后通过SMTP协议发送邮件进行告警。

以下是实现这一功能的步骤:1.导入所需的模块:```pythonimport subprocessimport smtplibfrom email.mime.text import MIMEText```2.定义一个函数,用于发送邮件:```pythondef send_email(subject, body, sender, receiver, smtp_server, smtp_port, username, password):msg = MIMEText(body)msg['Subject'] = subjectmsg['From'] = sendermsg['To'] = receivertry:server = smtplib.SMTP(smtp_server, smtp_port)server.starttlsserver.login(username, password)server.sendmail(sender, [receiver], msg.as_string() server.quitprint("邮件发送成功!")except Exception as e:print("发送邮件失败:", e)```3.定义一个函数,用于检测IP地址的存活性:```pythondef check_ip(ip):result = subprocess.run(['ping', '-c', '1', ip], capture_output=True)if result.returncode == 0:return Trueelse:return False```4.主程序逻辑:```pythonif __name__ == '__main__':ips = ['192.168.0.1', '192.168.0.2', '192.168.0.3'] # 要检测的IP地址列表smtp_port = 25 # SMTP服务器端口subject = 'IP存活性检测结果' # 邮件主题alive_ips = [] # 存活的IP地址列表for ip in ips:if check_ip(ip):alive_ips.append(ip)if len(alive_ips) > 0:#构造邮件正文body = '以下IP地址存活:\n'for ip in alive_ips:body += ip + '\n'#发送邮件send_email(subject, body, sender, receiver, smtp_server, smtp_port, username, password)else:print('所有IP地址都不存活!')```在以上代码中,我们首先定义了一个`check_ip`函数,用于检测IP 地址的存活性。

mimeutility decodetext -回复

mimeutility decodetext -回复

mimeutility decodetext -回复以下是根据主题"[mimeutility decodetext]"写的文章,介绍如何一步一步解码MIME文本。

MIME (Multipurpose Internet Mail Extensions) 是一种互联网标准,用于向电子邮件中添加非ASCII字符、多媒体内容和其他文件。

MIME文本是通过将原始二进制数据转换为文本字符来表示的。

在本文中,我们将学习如何使用mimeutillity解码MIME文本。

步骤1:安装mimeutility库首先,我们需要确保我们的Python环境中已安装了mimeutility库。

我们可以使用以下命令来安装该库:pip install mimeutility步骤2:导入mimeutility库安装完成后,我们需要导入mimeutility库,以便在我们的代码中使用它。

可以使用以下代码来导入mimeutility:pythonimport mimeutility步骤3:解码MIME文本现在,我们已经准备好解码MIME文本了。

首先,我们需要将MIME文本作为输入。

通常,MIME文本会以字符串的形式提供,我们可以将其存储在一个变量中。

pythonmime_text = "MIME文本内容"然后,我们可以使用mimeutility库中的decodetext()函数来解码MIME 文本。

以下是使用mimeutility解码MIME文本的代码示例:pythondecoded_text = mimeutility.decodetext(mime_text)步骤4:获取解码后的文本解码成功后,我们可以通过打印解码后的文本来查看结果。

以下是一个简单的示例:pythonprint(decoded_text)在这个示例中,我们使用print语句显示解码后的文本。

您可以根据需求进行更多的处理。

步骤5:完整代码示例pythonimport mimeutilitymime_text = "MIME文本内容"decoded_text = mimeutility.decodetext(mime_text)print(decoded_text)以上是使用mimeutility解码MIME文本的完整代码示例。

python中content的用法

python中content的用法

python中content的用法在Python中,content(内容)是一个常用的术语,通常用于表示数据或者文本的主体部分。

在不同的上下文中,content可以有不同的含义和用法。

下面将介绍一些常见的Python中content的用法。

1.网络请求:当使用Python进行网络请求时,content通常指的是HTTP响应的主体内容。

比如,使用`requests`库发送HTTP请求后,可以通过`response.content`来获取响应的内容,以字节形式表示。

可以将这个字节内容进行解码,得到可读的文本内容,例如使用`response.text`来获取文本内容。

2.文件操作:在文件操作中,content表示文件的内容。

比如,我们可以使用`open(`函数打开文件,并通过`file.read(`方法读取文件的内容,将其存储在一个变量中,即content。

我们可以对这个变量进行操作,如打印出内容、进行处理、保存到其他文件等。

3.数据处理:在数据处理中,content表示一组数据的集合,可以是列表、数值、字符串等。

这些数据可以存储在集合数据类型中,如列表、元组、集合、字典等。

通常,我们可以使用各种方法对这些数据进行处理,如访问、修改、删除、添加等。

4.网页爬虫:在网络爬虫中,content指的是从网页中提取的主体内容。

可以通过向网页发送请求,并使用库如`BeautifulSoup`或`Scrapy`来解析网页,并提取出所需的内容,存储在content中。

5.文本处理:在文本处理中,content表示文本的主体部分。

可以将文本读取到字符串中,然后对这个字符串进行各种操作,如分词、替换、提取关键词、统计词频等。

6.API调用:在使用API时,content是指从API请求中得到的主体内容。

可以使用相关库(如`requests`)向API发送请求,并通过`response.content`来获取API的响应内容。

rfc9293引用

rfc9293引用

rfc9293引用RFC 9293引用是一个网络通讯协议,主要用于在电子邮件通讯中引用过去的信息和文献。

RFC 9293标准主要定义了一个新的MIME头字段,使得在电子邮件和其他类型的消息中引用过去的信息和文献更加方便和通用。

使用RFC 9293引用,有如下几个步骤:1.在需要引用的信息或文献前,添加一个特定的MIME头字段"References"。

该字段可以包含多个值,每个值之间用逗号分隔。

每个值是一个唯一的消息标识符(Message-Id),用于标识被引用的那个消息。

2.在引用当中,使用MIME头字段"In-Reply-To"来声明被回复的消息的Message-Id。

如果引用的是多个消息,则使用一个空格来分隔Message-Id。

需要注意的是,In-Reply-To字段只用于建立引用关系,并不用于表示消息的主要内容。

3.对于被引用的消息,需要在被引用的消息中添加一个特定的MIME头字段"Message-Id"和"In-Reply-To"字段。

"Message-Id"字段用于唯一标识该消息,而"In-Reply-To"字段则用于指明该消息所针对的上一条消息的Message-Id。

如果该消息不是针对任何消息进行回复的话,则该字段可以为空。

4.当每个邮件客户端支持RFC 9293时,在查看邮件时,可以直接跟踪到被引用的消息,从而更加方便地查看整个邮件的上下文和历史。

RFC 9293引用的优点在于,可以方便地跟踪整个电子邮件的历史记录,从而更好地理解邮件的语境和主题。

另外,RFC 9293引用还可以检查消息的正确性,防止恶意的篡改和欺骗。

总之,RFC 9293引用是一个非常有用的技术标准,可以帮助用户更好地管理和理解电子邮件。

如果你经常使用电子邮件进行沟通和合作,那么建议你了解和使用RFC 9293引用。

www-rfc-editor-org

www-rfc-editor-org

Network Working Group J. Palme Request for Comments: 2076 Stockholm University/KTH Category: Informational February 1997Common Internet Message HeadersStatus of this MemoThis memo provides information for the Internet community. This memo does not specify an Internet standard of any kind. Distribution of this memo is unlimited.AbstractThis memo contains a table of commonly occurring headers in headings of e-mail messages. The document compiles information from other RFCs such as RFC 822, RFC 1036, RFC 1123, RFC 1327, RFC 1496, RFC 1521,RFC 1766, RFC 1806, RFC 1864 and RFC 1911. A few commonly occurring headers which are not defined in RFCs are also included. For eachheader, the memo gives a short description and a reference to the RFC in which the header is defined.Table of contents1. Introduction (2)2. Use of gatewaying headers (3)3. Table of headers (3)3.1 Phrases used in the tables (3)3.2 Trace information (5)3.3 Format and control information (5)3.4 Sender and recipient indication (6)3.5 Response control (9)3.6 Message identification and referral headers (11)3.7 Other textual headers (12)3.8 Headers containing dates and times (13)3.9 Quality information (13)3.10 Language information (14)3.11 Size information (14)3.12 Conversion control (15)3.13 Encoding information (15)3.14 Resent-headers (16)3.15 Security and reliability (16)3.16 Miscellaneous (16)4. Acknowledgments (18)Palme Informational [Page 1] RFC 2076 Internet Message Headers February 19975. References (18)6. Author's Address (20)Appendix A:Headers sorted by Internet RFC document in which they appear. 21Appendix B:Alphabetical index (25)1. IntroductionMany different Internet standards and RFCs define headers which may occur on Internet Mail Messages and Usenet News Articles. Theintention of this document is to list all such headers in onedocument as an aid to people developing message systems or interested in Internet Mail standards.The document contains all headers which the author has found in the following Internet standards: , RFC 822 [2], RFC 1036 [3], RFC 1123 [5], RFC 1327 [7], RFC 1496 [8], RFC 1521 [11], RFC 1766 [12], RFC1806 [14], RFC 1864[17] and RFC 1911[20]. Note in particular thatheading attributes defined in PEM (RFC 1421-1424) and MOSS (RFC 1848 [16]) are not included. PEM and MOSS headers only appear inside the body of a message, and thus are not headers in the RFC 822 sense.3.9 Priority3.2 ReceivedRecipient, see To, cc, bcc, Alternate-Recipient, Disclose-Recipient3.6 References3.8 Reply-By3.4 Reply-To, see also In-Reply-To, References3.14 Resent-Return see also Content-Return3.2 Return-PathPalme Informational [Page 26] RFC 2076 Internet Message Headers February 19973.5 Return-Receipt-To3.6 See-Also3.4 Sender3.9 Sensitivity3.16 Status3.7 Subject3.7 Summary3.6 Supersedes3.4 Telefax3.4 ToTransfer-Encoding see Content-Transfer-EncodingType see Content-Type, Message-Type, Original-Encoded-Information-TypesVersion, see MIME-Version, X-Mailer3.4 X400-Content-Return3.4 X-Mailer see also Mail-System-Version3.4 X-Newsreader3.15 XrefPalme Informational [Page 27]。

content-description讲解

content-description讲解

`content-description` 是一个 HTTP 响应头字段,主要用于描述文档的内容。

它不是 MIME 类型的一部分,而是一个额外的元数据,可以帮助客户端更好地理解响应的内容。

在大多数情况下,`content-description` 字段是由服务器设置的,并包含有关响应内容的简短描述。

这个描述可以包含任何文本,但通常会使用简短的关键词或短语来概括响应的内容。

虽然 `content-description` 字段不是强制性的,但一些辅助技术(如屏幕阅读器)可能会使用这个字段来提供对内容的额外信息,以便更好地为用户服务。

需要注意的是,由于 `content-description` 是一个非标准的HTTP 头字段,因此并不是所有的 HTTP 客户端或服务器都会支持它。

在使用这个字段时,需要考虑到兼容性和可用性问题。

[JavaMail]8 详解Message和MIME

[JavaMail]8 详解Message和MIME

A.0、MIMEMultipurpose Internet Mail Extension(多功能Internet 邮件扩充服务)它是一种多用途网际邮件扩充协议,在1992年最早应用于电子邮件系统,但后来也应用到浏览器。

服务器会将它们发送的多媒体数据的类型告诉浏览器,而通知手段就是说明该多媒体数据的MIME类型,从而让浏览器知道接收到的信息哪些是MP3文件,哪些是Shockwave文件等等。

服务器将MIME标志符放入传送的数据中来告诉浏览器使用哪种插件读取相关文件。

MIME能够支持非ASCII字符、二进制格式附件等多种格式的邮件消息。

这个标准被定义在; RFC 2045,; RFC 2046,; RFC 2047,; RFC 2048,; RFC 2049等RFC中。

由RFC 822转变而来的RFC 2822,规定电子邮件标准并不允许在邮件消息中使用7位ASCII字符集以外的字符。

正因如此,一些非英语字符消息和二进制文件,图像,声音等非文字消息都不能在电子邮件中传输。

MIME规定了用于表示各种各样的数据类型的符号化方法。

MIME意为多功能Internet邮件扩展,它设计的最初目的是为了在发送电子邮件时附加多媒体数据,让邮件客户程序能根据其类型进行处理。

然而当它被HTTP协议支持之后,它的意义就更为显著了。

它使得HTTP传输的不仅是普通的文本,而变得丰富多彩。

由于MIME类型与文档的后缀相关,因此服务器使用文档的后缀来区分不同文件的MIME类型,服务器中必须定义文档后缀和MIME类型之间的对应关系。

而客户程序从服务器上接收数据的时候,它只是从服务器接受数据流,并不了解文档的名字,因此服务器必须使用附加信息来告诉客户程序数据的MIME类型。

服务器在发送真正的数据之前,就要先发送标志数据的MIME类型的信息,这个信息使用Content-type关键字进行定义,例如对于HTML文档,服务器将首先发送以下(Content-type: text/html)MIME标识信息,这个标识并不是真正的数据文件的一部分。

python email mimemultipart 参数

python email mimemultipart 参数

python email mimemultipart 参数**《Python邮件处理中的mimemultipart参数》**在Python中,处理邮件时,我们经常需要创建和发送包含多种类型附件的邮件。

在这种情况下,mimemultipart参数就显得尤为重要。

它允许我们在邮件正文中包含多种类型的附件,如文本、HTML、图片等。

一、基本用法mimemultipart参数是一个类,用于创建multipart/mixed类型的邮件。

它通常与smtp库一起使用,用于发送邮件。

```pythonfrom email.mime.multipart import MIMEMultipartfrom email.mime.text import MIMETextfrom email.mime.image import MIMEImage```二、参数详解mimemultipart参数的基本用法如下:```pythonmultipart = MIMEMultipart('alternative')```这里,'alternative'表示邮件内容可以是文本或HTML,并以两者中的任意一种形式呈现。

你可以根据需要选择不同的类型,如'mixed'(多种类型同时存在),'mixed'将邮件正文视为一个容器,可以包含多种类型的附件。

三、添加文本和图片附件使用mimemultipart参数,我们可以很方便地添加文本和图片附件。

以下是一个简单的例子:```pythontext = '这是一段文本内容'image_path = 'path/to/image.jpg'part1 = MIMEText(text, 'plain')part2 = MIMEImage(open(image_path, 'rb').read(), 'image') ```然后,将这两个部分添加到multipart对象中:```pythonmultipart.attach(part1)multipart.attach(part2)```四、发送邮件最后,我们可以通过smtp库将multipart对象发送出去:```pythonimport smtplibfrom email.mime.multipart import MIMEMultipartfrom email.mime.text import MIMETextfrom email.mime.image import MIMEImagefrom email.utils import formataddrfrom address import your_email # 请替换为你的邮箱地址from password import your_password # 请替换为你的邮箱密码```以上就是Python邮件处理中mimemultipart参数的基本用法和相关内容。

python email class用法

python email class用法

python email class用法Python Email Class用法本文将介绍Python中的Email Class以及其常见用法。

以下是一些用法,并详细讲解:创建Email对象•创建一个Email对象:import smtplibfrom import MIMEText# 创建一个MIMEText对象,作为邮件的内容message = MIMEText('这是一封测试邮件。

')# 设置发件人地址message['From'] = ''# 设置收件人地址message['To'] = ''# 设置邮件主题message['Subject'] = '测试邮件'# 创建SMTP对象smtpObj = ('', 25)# 登录SMTP服务器('username', 'password')# 发送邮件('', '', _string())# 退出SMTP服务器()以上代码创建了一个Email对象,并通过SMTP服务器发送了一封测试邮件。

添加附件•添加一个附件:from import MIMEMultipartfrom import MIMEBase# 创建一个MIMEMultipart对象,作为邮件的容器message = MIMEMultipart()# 设置发件人地址message['From'] = ''# 设置收件人地址message['To'] = ''# 设置邮件主题message['Subject'] = '测试邮件'# 创建一个MIMEBase对象,作为附件内容并添加到容器中part = MIMEBase('application', 'octet-stream')with open('', 'rb') as file:_payload(())_header('Content-Disposition', 'attachment', filename='') (part)# 创建SMTP对象、登录SMTP服务器并发送邮件# ...# 退出SMTP服务器()以上代码在邮件中添加了一个名为``的附件。

getting multipart files content bytes error

getting multipart files content bytes error

getting multipart files contentbytes error在处理多部分文件(multipart files)时,如果遇到获取文件内容字节的错误,可能有几个潜在的原因。

这些原因通常与文件上传、文件读取或处理多部分数据流的逻辑有关。

下面是一些可能的原因和相应的解决方案:1. 文件格式问题原因:文件可能不是有效的多部分文件,或者格式不正确。

解决方案:确保上传的文件是多部分文件,并且格式正确。

检查文件头是否包含正确的边界标记。

2. 文件编码问题原因:文件可能使用了不正确的字符编码。

解决方案:确保在处理文件时使用正确的字符编码,例如UTF-8。

3. 文件读取错误原因:在读取文件时可能发生了错误,例如文件路径不正确、文件不存在或权限问题。

解决方案:检查文件路径和权限设置,确保文件可以正确读取。

4. 内存不足原因:如果文件过大,可能会导致内存不足。

解决方案:考虑增加内存或优化代码以减少内存使用。

5. 库或框架使用问题原因:如果使用了某个库或框架来处理多部分文件,可能存在使用不当或版本不兼容的问题。

解决方案:确保正确使用了库或框架,并考虑升级或降级到合适的版本。

6. 边界处理错误原因:在处理多部分文件的边界时可能出现了错误。

解决方案:仔细检查并正确处理多部分文件的边界。

示例代码(Python)下面是一个使用Python处理多部分文件的简单示例:pythonfrom email.parser import Parserfrom email.message import Messageimport iodef parse_multipart_file(file_path):with open(file_path, 'rb') as file:data = file.read()msg = Message()msg.set_payload(data)parser = Parser()parts = parser.parsestr(msg.as_string())for part in parts:content_type = part.get_content_type()content_disposition = str(part.get("Content-Disposition")) if "attachment" not in content_disposition:continuefilename = part.get_filename()if not filename:continuewith open(filename, 'wb') as f:f.write(part.get_payload(decode=True))# 使用示例parse_multipart_file('path/to/multipart/file')这个示例代码使用Python的email模块来解析多部分文件,并将每个附件保存到磁盘上。

python imap使用用法

python imap使用用法

python imap使用用法在Python中,我们可以使用imaplib库来操作IMAP。

以下是一段使用IMAP在Python中获取邮件的基本代码示例:```pythonimport imaplibimport emailfrom import decode_header连接到Gmail邮箱imap_host = ''imap_port = 993mail = _SSL(imap_host, imap_port)登录到Gmail邮箱username = ''password = 'your_password'(username, password)选择收件箱("inbox")搜索邮件result, data = (None, "SUBJECT Python IMAP")获取搜索结果中的第一封邮件result, email_data = (data[0], '(RFC822)')raw_email = email_data[0][1].decode("utf-8")email_message = _from_string(raw_email)subject = decode_header(email_message["Subject"])[0][0]from_name, from_email = (email_message["From"])print(f"主题:{subject}")print(f"发件人:{from_name}({from_email})")关闭并退出邮箱()()```这段代码首先连接到Gmail的IMAP服务器,然后登录到你的Gmail账户,接着选择要操作的邮箱文件夹(在此例中为收件箱),然后搜索主题为"Python IMAP"的邮件,并获取该搜索结果中的第一封邮件,最后打印出这封邮件的主题和发件人。

email.mime.text包的用法

email.mime.text包的用法

em本人l.mime.text包是Python中用于处理文本消息的标准库之一。

它提供了一种方便的方式来创建和处理MIME(Multipurpose Internet M本人l Extensions)格式的邮件消息,这使得程序员可以轻松地构建和发送各种类型的邮件。

在本文中,我们将介绍em本人l.mime.text包的基本用法,包括创建文本消息、设置发件人、收件人和主题等信息,以及将消息发送给邮件服务器。

我们还将讨论如何附加附件和处理回复邮件。

1. 创建文本消息要创建一个纯文本消息,我们可以使用em本人l.mime.text库中的MIMEText类。

通过指定文本内容、字符编码和MIME子类型,我们可以轻松地创建一个简单的文本消息。

```pythonfrom em本人l.mime.text import MIMETextmsg = MIMEText("这是一封测试邮件。

", "pl本人n", "utf-8")msg["From"] = "senderexample"msg["To"] = "recipientexample"msg["Subject"] = "测试邮件"```2. 设置发件人、收件人和主题我们可以使用MIMEText对象的标准邮件头部来设置发件人、收件人和主题等信息。

这些信息将在邮件被发送时显示在邮件客户端中。

```pythonmsg["From"] = "senderexample"msg["To"] = "recipientexample"msg["Subject"] = "测试邮件"```3. 发送消息一旦我们创建了MIMEText对象并设置了必要的邮件头部信息,我们就可以使用Python内置的smtplib库将消息发送给邮件服务器。

sendinfo函数用法

sendinfo函数用法

sendinfo函数用法1.函数参数:- 主题(subject):发送信息的主题或标题。

- 内容(content):发送信息的具体内容。

2.函数返回值:-该函数可能有不同的返回值,具体情况取决于编写函数时所定义的逻辑。

例如,可以设置返回发送成功或发送失败的状态值,或者返回发送的信息或其它相关数据。

3.函数实现:-函数的具体实现会根据不同的编程语言和目标平台而有所不同。

一种可能的实现方式是通过内置的电子邮件发送库或API来发送电子邮件。

另一种方式是通过网络请求来发送数据,可以使用HTTP请求库或其它网络通信方式。

4.使用示例:- 下面是一个基于 Python 的示例代码,使用 sendinfo 函数发送电子邮件:```pythonimport smtplibfrom email.mime.text import MIMETextdef sendinfo(recipient, subject, content):#配置SMTP服务器smtp_port = 587 # 设置SMTP服务器端口(一般为587)#发送者信息#构建邮件内容msg = MIMEText(content)msg['Subject'] = subjectmsg['From'] = sendermsg['To'] = recipienttry:#连接到SMTP服务器server = smtplib.SMTP(smtp_server, smtp_port) server.starttlsserver.login(sender, password)#发送邮件server.sendmail(sender, [recipient], msg.as_string() server.quitreturn 'Sending successful!'except Exception as e:return 'Sending failed: ' + str(e)```- 上述示例代码中,`sendinfo` 函数通过 SMTP 协议发送邮件。

Mimecast Large File Send Quick Start Guide

Mimecast Large File Send Quick Start Guide

Mimecast Large File Send Quick Start GuideWhat is Mimecast Large File Send? Mimecast Large File Send supports security and productivity by enabling employees to send and receive large files (under 2 GB) directly from Outlook, regardless of the attachment limits of their own or other parties ’ email system. It protects attachments with encryption, optional access key and custom expiration dates, and verifies receipt and download of files. It also archives all files and notifications according to email retention policies, supporting audit, e-discovery and compliance .This feature enables you to use Outlook instead of third-party sources that need to be sent and stored for up to 30 days.This guide includes information on how to use this feature from the following applications:• Mimecast Personal Portal.• Mimecast for Outlook.Mimecast Personal PortalTo use large file send from the Mimecast Personal Portal:1. Go to the Personal Portaland log in with your email address and Office 365/email password. The Mimecast password will automatically remain in sync as your office password changes.2. After selecting Next , you will be presented with two options. Select Mimecast Personal Portal .3. Select the Large File Send icon.4. Click Compose to open a new message window.5. Enter the recipient, subject and body message.6. Select Attach to add a file to the message.7. Select the Large File Send icon.8. Once you attach your files, proceed to Send with default settings or amend the available settings to suityour needs.9. Select OK.10. Select Send to send the message using Large File Send.Mimecast for OutlookYou can send attachments safely and securely via Large File Send in Mimecast for Outlook. Once a Large File Send message has been successfully sent, a notification will confirm the message was sent. Should a Large File Send message fail, use the Large File Send Manager to attempt to resend or cancel the message in question.If you are using a Windows device, view this guide to download the Mimecast for Outlook plug-in.If you are using a Mac, use this link to start the download process. If you need an Admin to complete the download, please contact the OMES Service Desk via email, our Tech Desk customer portal, or phone (405-521-HELP).Watch this video for more information on sending large files in Outlook.To send attachments via Large File Send from Microsoft Outlook:1. Open Outlook.2. Create a New Email.3. Click on the Mimecast tab.4. Click on the Attach Large Files icon.5. Select the file(s) you want to attach.Note:The selected files are attached to the message with a notification that they will be sent via Large File Send. You will not be able to preview them, so to ensure you are sending the correct files,check them before selecting.6. Click Send.7. This pop-up box will display default settings. You may also select the option to “Invite recipients to sendme large files,” if applicable.is successfully sent, and a sent notification message is displayed.Large File Send: Frequently asked questionsQ: Is there a minimum collective file size limit?A: Yes. Large File Send cannot process files that do not collectively exceed 1 MB. Should you have files of this size, either send them:•Via your email client.•Via the Personal Portal.Q:Is there a maximum collective file size limit?A: Yes. A maximum file size of 2 GB is allowed.Q:I've sent a file that was under the maximum file size allowed, but it seemed to have failed with an error stating it was over the maximum file size. What is going on?A: When sending an email message, its content goes through various security checks. This can mean attachments that are under the Large File Send maximum file size limit may increase insize over this limit. If this happens, separate the attachments and send them individually.Q:I'm trying to drag and drop files into a message, but this doesn't appear to work. What is going on?A: Large File Send does not support drag and drop functionality into Microsoft Office or other email clients. To add files to a message, you must use the Large File Send functionality available inthe Mimecast Personal Portal or the Mimecast ribbon in Outlook. Refer to the Mimecast PersonalPortal: Sending Attachments via Large File Send and Mimecast for Outlook: SendingAttachments via Large File Send webpages for further details.Q:If trying to securely send a large file using both Large File Send and Secure Messaging, but it appears that the message isn't being sent securely. Why is this?A: Unfortunately, the use of both Large File Send and Secure Messaging on the same message isn't supported. In this scenario, Large File Send is used to send the message, leaving the message'sbody unencrypted.。

rfc3986 uri的正则表达式

rfc3986 uri的正则表达式

rfc3986 uri的正则表达式以下是匹配RFC 3986 URI的正则表达式:```^(?:([A-Za-z]+):)?(\/\/(?:([^:@\/]*)(?::([^:@\/]*))?@)?([^:\/?#\[\]]+)(?::(\d+))?) (\/(?:[^?#\[\]]*\/)*)?([^?#\[\]]*)(\?(?:[^#\[\]]*))?(#(?:[^#\[\]]*))?$ ```这个正则表达式分为以下几部分:1. 方案(scheme)`(?:([A-Za-z]+):)?`匹配可选的方案部分,允许任何字母字符,在冒号之前以`:`结束。

2. 授权(authority)`(\/\/(?:([^:@\/]*)(?::([^:@\/]*))?@)?([^:\/?#\[\]]+)(?::(\d+))?)(\/(?:[ ^?#\[\]]*\/)*)?`匹配`//`之后,可以选择授权信息。

授权信息包含用户名、密码和主机。

它也可以包括可选的端口号和可选的绝对路径。

该部分的子表达式如下:- `\/\/`: 匹配两个斜杠。

- `(?:([^:@\/]*)(?::([^:@\/]*))?@)?`: 匹配可选的用户名、可选的密码和`@`符号。

- `([^:\/?#\[\]]+)`: 匹配不包含冒号、斜杠、问号、井号和方括号的字符,它就是主机名(host)。

- `(?::(\d+))?`: 匹配可选的端口号(port)。

- `(\/(?:[^?#\[\]]*\/)*)?`: 匹配可选的绝对路径部分(path)。

3. 查询字符串(query string)`([^?#\[\]]*)`匹配可选的查询字符串部分,查询字符串以`?`字符开始。

4. 片段标识符(fragment identifier)`(#(?:[^#\[\]]*))?`匹配可选的片段标识符,以`#`字符开始。

请注意,这个正则表达式并没有校验URI是否真正存在或是否有效。

contenttype翻译

contenttype翻译

contenttype翻译"contenttype"的中文翻译是"内容类型"。

在计算机科学和网络技术中,"contenttype"通常用于描述网络传输中的数据类型,以便接收方能够正确地识别和处理数据。

以下是一些使用"contenttype"的例句及其中英文对照:1. 在HTTP请求中,Content-Type头字段用于指定请求或响应消息的内容类型。

In an HTTP request, the Content-Type header field is used to specify the content type of the request or response message.2. 常见的Content-Type值包括"text/plain"(纯文本)、"application/json"(JSON数据)和"image/jpeg"(JPEG图片)。

Common Content-Type values include "text/plain" for plain text, "application/json" for JSON data, and "image/jpeg" for JPEG images.3. 在发送电子邮件时,Content-Type可指定邮件的正文内容类型,如"text/plain"或"text/html"。

When sending emails, the Content-Type can specify the content type of the email body, such as "text/plain" or "text/html".4. 在网络爬虫中,可以使用Content-Type来判断响应中的数据类型,以便进行相应的处理。

用curl抓取网站数据,仿造IP、防屏蔽终极强悍解决方式

用curl抓取网站数据,仿造IP、防屏蔽终极强悍解决方式

⽤curl抓取⽹站数据,仿造IP、防屏蔽终极强悍解决⽅式下⾯⾔归正传,先说⼀种常见的⽅式,伪造来源IP,这也是好多刷票朋友常⽤的⽅法:
1、简单⼀点的可以在header伪造X-FORWARDED-FOR,并伪造referer,代码如下:
[php]
1. curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-FORWARDED-FOR:111.22
2.33
3.4', 'CLIENT-IP:111.222.333.4'));
2. curl_setopt($ch, CURLOPT_REFERER, "");
2、上⾯的⽅法⼤多数能糊弄过去,但也有抓到了真实IP的。

就使⽤代理,⿇烦在于你有⼀个有效的代理ip和端⼝号,有的还需要⽤户名密码,代码如下:
[php]
1. curl_setopt($ch, CURLOPT_PROXY, "http://111.22
2.33
3.4:110");
另外还有⼀种情况,就是⽤浏览器可以访问,⽤curl就是不⾏,发现对⽅检查了useragent,如果没有就认为是抓取等⾮法来源,那么我们就⾃⼰在header加上useragent,代码如下:
[php]
1. curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.113
2.57 Safari/536.11");。

imap标准附件名

imap标准附件名

imap标准附件名全文共四篇示例,供读者参考第一篇示例:IMAP标准附件名是指在使用IMAP协议接收电子邮件时,附件的命名规范。

IMAP(Internet Message Access Protocol)是一种用于从邮件服务器接收电子邮件的协议,与POP(Post Office Protocol)类似,但功能更加丰富。

在IMAP标准中,附件的命名规范是非常重要的,因为这直接影响到用户如何查看、下载和保存邮件附件。

Content-Disposition是指附件的展示方式,包括inline(内嵌显示)和attachment(作为附件下载)。

对于attachment类型的附件,通常还包括一个filename参数,用来指定附件的文件名。

文件名可以是任意字符集编码的字符串,但建议使用UTF-8编码来避免乱码问题。

在IMAP协议中,附件的文件名通常会经过一定的编码处理,以确保在不同的邮件客户端上能够正确显示和保存。

常见的编码方式包括Base64、Quoted-Printable等。

Base64编码将文件名转换为一串基于64个字符的编码序列,可以避免中文和特殊字符的兼容性问题。

Quoted-Printable编码则是将文件名转换为等号+两位十六进制数字表示的方式,也能够保证文件名的可读性和兼容性。

IMAP标准附件名的一个常见问题是文件名过长或包含特殊字符,这可能导致邮件客户端无法正确显示附件或保存附件。

为了避免这种问题,建议发送方在命名附件时使用简洁清晰的文件名,并尽量避免包含特殊字符和空格。

接收方在下载附件时也需要注意查看文件名是否符合规范,避免出现问题。

IMAP标准附件名的规范性和兼容性对于邮件的正确传输和展示至关重要。

发送方和接收方都需要遵循标准来命名和解析附件,以确保用户能够顺利查看和保存邮件附件。

希望本文能够帮助读者更好地理解和应用IMAP标准附件名规范,提升邮件通讯的效率和便利性。

第二篇示例:IMAP(Internet Message Access Protocol)是一种用于检索电子邮件的标准协议,它允许用户通过远程服务器访问和管理电子邮件。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

Network Working Group N. Borenstein Request for Comments: 1563 Bellcore Obsoletes: 1523 January 1994 Category: InformationalThe text/enriched MIME Content-typeStatus of this MemoThis memo provides information for the Internet community. This memo does not specify an Internet standard of any kind. Distribution ofthis memo is unlimited.AbstractMIME [RFC-1341, RFC-1521] defines a format and general framework for the representation of a wide variety of data types in Internet mail. This document defines one particular type of MIME data, thetext/enriched type, a refinement of the "text/richtext" type defined in RFC 1341. The text/enriched MIME type is intended to facilitatethe wider interoperation of simple enriched text across a widevariety of hardware and software platforms.Table of ContentsThe Text/enriched MIME type (2)Formatting Commands (4)Font-Alteration Commands (4)Fill/Justification Commands (5)Indentation Commands (6)Miscellaneous Commands (6)Balancing and Nesting of Formatting Commands (7)Unrecognized formatting commands (8)White Space in Text/enriched Data (8)Initial State of a text/enriched interpreter (8)Non-ASCII character sets (8)Minimal text/enriched conformance (9)Notes for Implementors (9)Extensions to text/enriched (10)An Example (11)Security Considerations (12)Author’s Address (12)Acknowledgements (12)References (12)Appendix A -- A Simple enriched-to-plain Translator in C. 13Appendix B -- Differences from RFC 1341 text/richtext (15)Borenstein [Page 1]The Text/enriched MIME typeIn order to promote the wider interoperability of simple formattedtext, this document defines an extremely simple subtype of the MIMEcontent-type "text", the "text/enriched" subtype. This subtype wasdesigned to meet the following criteria:1. The syntax must be extremely simple to parse,so that even teletype-oriented mail systems caneasily strip away the formatting information andleave only the readable text.2. The syntax must be extensible to allow for newformatting commands that are deemed essential forsome application.3. If the character set in use is ASCII or an 8-bit ASCII superset, then the raw form of the datamust be readable enough to be largelyunobjectionable in the event that it is displayedon the screen of the user of a non-MIME-conformantmail reader.4. The capabilities must be extremely limited, toensure that it can represent no more than islikely to be representable by the user’s primaryword processor. While this limits what can besent, it increases the likelihood that what issent can be properly displayed.This document defines a new MIME content-type, "text/enriched". The content-type line for this type may have one optional parameter, the "charset" parameter, with the same values permitted for the"text/plain" MIME content-type.The syntax of "text/enriched" is very simple. It represents text in a single character set -- US-ASCII by default, although a differentcharacter set can be specified by the use of the "charset" parameter. (The semantics of text/enriched in non-ASCII character sets arediscussed later in this document.) All characters representthemselves, with the exception of the "<" character (ASCII 60), which is used to mark the beginning of a formatting command. Formattinginstructions consist of formatting commands surrounded by anglebrackets ("<>", ASCII 60 and 62). Each formatting command may be no more than 60 characters in length, all in US-ASCII, restricted to the alphanumeric and hyphen ("-") characters. Formatting commands may be preceded by a solidus ("/", ASCII 47), making them negations, andsuch negations must always exist to balance the initial opening Borenstein [Page 2]commands. Thus, if the formatting command "<bold>" appears at somepoint, there must later be a "</bold>" to balance it. (NOTE: The 60 character limit on formatting commands does NOT include the "<", ">", or "/" characters that might be attached to such commands.)Formatting commands are always case-insensitive. That is, "bold" and "BoLd" are equivalent in effect, if not in good taste.Beyond tokens delimited by "<" and ">", there are two other specialprocessing rules. First, a literal less-than sign ("<") can berepresented by a sequence of two such characters, "<<". Second, line breaks (CRLF pairs in standard network representation) are handledspecially. In particular, isolated CRLF pairs are translated into a single SPACE character. Sequences of N consecutive CRLF pairs,however, are translated into N-1 actual line breaks. This permitslong lines of data to be represented in a natural- looking mannerdespite the frequency of line-wrapping in Internet mailers. Whenpreparing the data for mail transport, isolated line breaks should be inserted wherever necessary to keep each line shorter than 80characters. When preparing such data for presentation to the user,isolated line breaks should be replaced by a single SPACE character, and N consecutive CRLF pairs should be presented to the user as N-1line breaks.Thus text/enriched data that looks like this:This isa singlelineThis is thenext line.This is thenext paragraph.should be displayed by a text/enriched interpreter as follows:This is a single lineThis is the next line.This is the next paragraph.The formatting commands, not all of which will be implemented by all implementations, are described in the following sections.Borenstein [Page 3]Formatting CommandsThe text/enriched formatting commands all begin with <commandname>and end with </commandname>, affecting the formatting of the textbetween those two tokens. The commands are described here, groupedaccording to type.Font-Alteration CommandsThe following formatting commands are intended to alter the font inwhich text is displayed, but not to alter the indentation orjustification state of the text:Bold -- causes the affected text to be in a bold font. Nested bold commands have the same effect as a single boldcommand.Italic -- causes the affected text to be in an italic font.Nested italic commands have the same effect as a singleitalic command.Fixed -- causes the affected text to be in a fixed width font. Nested fixed commands have the same effect as a singlefixed command.Smaller -- causes the affected text to be in a smaller font.It is recommended that the font size be changed by twopoints, but other amounts may be more appropriate in some environments. Nested smaller commands produce ever-smaller fonts, to the limits of the implementation’scapacity to reasonably display them, after which furthersmaller commands have no incremental effect.Bigger -- causes the affected text to be in a bigger font. It is recommended that the font size be changed by twopoints, but other amounts may be more appropriate in some environments. Nested bigger commands produce ever-bigger fonts, to the limits of the implementation’s capacity toreasonably display them, after which further biggercommands have no incremental effect.Underline -- causes the affected text to be underlined. Nested underline commands have the same effect as a singleunderline command.While the "bigger" and "smaller" operators are effectively inverses, it is not recommended, for example, that "<smaller>" be used to endthe effect of "<bigger>". This is properly done with "</bigger>". Borenstein [Page 4]Fill/Justification CommandsInitially, text/enriched text is intended to be displayed fullyfilled with appropriate kerning and letter-tracking as suits thecapabilities of the receiving user agent software. Actual line width is left to the discretion of the receiver, which is expected to foldlines intelligently (preferring soft line breaks) to the best of itsability.The following commands alter that state. Each of these commandsforce a line break before and after the formatting environment ifthere is not otherwise a line break. For example, if one of thesecommands occurs anywhere other than the beginning of a line of textas presented, a new line is begun.Center -- causes the affected text to be centered.FlushLeft -- causes the affected text to be left-justified with aragged right margin.FlushRight -- causes the affected text to be right-justified with a ragged left margin.FlushBoth -- causes the affected text to be filled and padded soas to create smooth left and right margins, i.e., to befully justified.Nofill -- causes the affected text to be displayed without filling or justification.The center, flushleft, flushright, and flushboth commands aremutually exclusive, and, when nested, the inner command takesprecedence.Whether or not text is justified by default (that is, whether thedefault environment is flushleft, flushright, or flushboth) isunspecified, and depends on the preferences of the user, thecapabilities of the local software and hardware, and the nature ofthe character set in use. On systems where justification isconsidered undesirable, the flushboth environment may be identical to the default environment. Note that justification should never beperformed inside of center, flushleft, flushright, or nofillenvironments. Note also that for some non-ASCII character sets, full justification may be fundamentally inappropriate.Borenstein [Page 5]Indentation CommandsInitially, text/enriched text is displayed using the maximumavailable margins. Two formatting commands may be used to affect the margins.Indent -- causes the running left margin to be moved to theright. The recommended indentation change is the width of four characters, but this may differ amongimplementations.IndentRight -- causes the running right margin to be moved tothe left. The recommended indentation change is the width of four characters, but this may differ amongimplementations.A line break is NOT forced by a change of the margin, to permit thedescription of "hanging" text. Thus for example the following text: Now <indent> is the time for all good horses to come to the aid oftheir stable, assuming that </indent> any stable is really stable.would be displayed in a 40-character-wide window as follows:Now is the time for all good horses tocome to the aid of their stable,assuming that any stable isreally stable.Miscellaneous CommandsExcerpt -- causes the affected text to be interpreted as atextual excerpt from another source, probably a messagebeing responded to. Typically this will be displayedusing indentation and an alternate font, or by indentinglines and preceding them with "> ", but such decisions are up to the implementation. (Note that this is the onlytruly declarative markup construct in text/enriched, andas such doesn’t fit very well with the other facilities,but it describes a type of markup that is very commonlyused in email and has no procedural analogue.) Note that as with the justification commands, the excerpt commandimplicitly begins and ends with a line break if one is not already there.Borenstein [Page 6]Param -- Marks the affected text as command parameters, to beinterpreted or ignored by the text/enriched interpreter,but NOT to be shown to the reader. The syntax of theparameter data (whatever appears between the initial"<param>" and the terminating "</param>") is leftundefined by this memo, to be defined by text/enrichedextensions in the future. However, the format of suchdata must NOT contain nested <param> commands, and either must NOT use the "<" character or must use it in a waythat is compatible with text/enriched parsing. That is,the end of the parameter data should be recognizable with EITHER of two algorithms: simply searching for the firstoccurence of "</param>" or parsing until a balanced"</param>" command is found. In either case, however, the parameter data should NOT be shown to the human reader. Balancing and Nesting of Formatting CommandsPairs of formatting commands must be properly balanced and nested.Thus, a proper way to describe text in bold italics is:<bold><italic>the-text</italic></bold>or, alternately,<italic><bold>the-text</bold></italic>but, in particular, the following is illegaltext/enriched:<bold><italic>the-text</bold></italic>The nesting requirement for formatting commands imposes a slightlyhigher burden upon the composers of text/enriched bodies, butpotentially simplifies text/enriched displayers by allowing them tobe stack-based. The main goal of text/enriched is to be simpleenough to make multifont, formatted email widely readable, so thatthose with the capability of sending it will be able to do so withconfidence. Thus slightly increased complexity in the composingsoftware was deemed a reasonable tradeoff for simplified readingsoftware. Nonetheless, implementors of text/enriched readers areencouraged to follow the general Internet guidelines of beingconservative in what you send and liberal in what you accept. Those implementations that can do so are encouraged to deal reasonably with improperly nested text/enriched data.Borenstein [Page 7]Unrecognized formatting commandsImplementations must regard any unrecognized formatting command as"no-op" commands, that is, as commands having no effect, thusfacilitating future extensions to "text/enriched". Privateextensions may be defined using formatting commands that begin with"X-", by analogy to Internet mail header field names.In order to formally define extended commands, a new Internetdocument should be published.White Space in Text/enriched DataNo special behavior is required for the SPACE or TAB (HT) character. It is recommended, however, that, at least when fixed-width fonts are in use, the common semantics of the TAB (HT) character should beobserved, namely that it moves to the next column position that is a multiple of 8. (In other words, if a TAB (HT) occurs in column n,where the leftmost column is column 0, then that TAB (HT) should bereplaced by 8-(n mod 8) SPACE characters.) It should also be notedthat some mail gateways are notorious for losing (or, less commonly, adding) white space at the end of lines, so reliance on SPACE or TAB characters at the end of a line is not recommended.Initial State of a text/enriched interpreterText/enriched is assumed to begin with filled text in a variable-width font in a normal typeface and a size that is average for thecurrent display and user. The left and right margins are assumed to be maximal, that is, at the leftmost and rightmost acceptablepositions.Non-ASCII character setsIf the character set specified by the charset parameter on theContent-type line is anything other than "US-ASCII", this means that the text being described by text/enriched formatting commands is in a non-ASCII character set. However, the commands themselves are still the same ASCII commands that are defined in this document. Thiscreates an ambiguity only with reference to the "<" character, theoctet with numeric value 60. In single byte character sets, such as the ISO-8859 family, this is not a problem; the octet 60 can bequoted by including it twice, just as for ASCII. The problem is more complicated, however, in the case of multi-byte character sets, where the octet 60 might appear at any point in the byte sequence for anyof several characters.Borenstein [Page 8]In practice, however, most multibyte character sets address thisproblem internally. For example, the ISO-2022 family of charactersets can switch back into ASCII at any moment. Therefore it isspecified that, before text/enriched formatting commands, theprevailing character set should be "switched back" into ASCII, andthat only those characters which would be interpreted as "<" in plain text should be interpreted as token delimiters in text/enriched.The question of what to do for hypothetical future character setsthat do NOT subsume ASCII is not addressed in this memo.Minimal text/enriched conformanceA minimal text/enriched implementation is one that converts "<<" to"<", removes everything between a <param> command and the nextbalancing </param> command, removes all other formatting commands(all text enclosed in angle brackets), and, outside of <nofill>environments, converts any series of n CRLFs to n-1 CRLFs, andconverts any lone CRLF pairs to SPACE.Notes for ImplementorsIt is recognized that implementors of future mail systems will wantrich text functionality far beyond that currently defined fortext/enriched. The intent of text/enriched is to provide a commonformat for expressing that functionality in a form in which much ofit, at least, will be understood by interoperating software. Thus,in particular, software with a richer notion of formatted text thantext/enriched can still use text/enriched as its basicrepresentation, but can extend it with new formatting commands and by hiding information specific to that software system in text/enriched <param> constructs. As such systems evolve, it is expected that the definition of text/enriched will be further refined by futurepublished specifications, but text/enriched as defined here provides a platform on which evolutionary refinements can be based.An expected common way that sophisticated mail programs will generate text/enriched data is as part of a multipart/alternative construct.For example, a mail agent that can generate enriched mail in ODAformat can generate that mail in a more widely interoperable form by generating both text/enriched and ODA versions of the same data,e.g.:Borenstein [Page 9]Content-type: multipart/alternative; boundary=foo--fooContent-type: text/enriched[text/enriched version of data]--fooContent-type: application/oda[ODA version of data]--foo--If such a message is read using a MIME-conformant mail reader thatunderstands ODA, the ODA version will be displayed; otherwise, thetext/enriched version will be shown.In some environments, it might be impossible to combine certaintext/enriched formatting commands, whereas in others they might becombined easily. For example, the combination of <bold> and <italic> might produce bold italics on systems that support such fonts, butthere exist systems that can make text bold or italicized, but notboth. In such cases, the most recently issued (innermost) recognized formatting command should be preferred.One of the major goals in the design of text/enriched was to make it so simple that even text-only mailers will implement enriched-to-plain-text translators, thus increasing the likelihood that enriched text will become "safe" to use very widely. To demonstrate thissimplicity, an extremely simple C program that converts text/enriched input into plain text output is included in Appendix A.Extensions to text/enrichedIt is expected that various mail system authors will desireextensions to text/enriched. The simple syntax of text/enriched, and the specification that unrecognized formatting commands should simply be ignored, are intend to promote such extensions.Beyond simply defining new formatting commands, however, it maysometimes be necessary to define formatting commands that can takearguments. This is the intended use of the <param> construct. Inparticular, software that wished to extend text/enriched to includecolored text might define an "x-color" environment which always began with a color name parameter, to indicate the desired color for theaffected text.Borenstein [Page 10]An ExamplePutting all this together, the following "text/enriched" bodyfragment:From: Nathaniel Borenstein <nsb@>To: Ned Freed <ned@>Content-type: text/enriched<bold>Now</bold> is the time for<italic>all</italic> good men<smaller>(and <<women>)</smaller> to<ignoreme>come</ignoreme>to the aid of their<x-color><param>red</param>beloved</x-color>country.By the way, I think that <<smaller>shouldREALLY be called<<tinier>and that I am always right.-- the endrepresents the following formatted text (which will, no doubt, looksomewhat cryptic in the text-only version of this document):Now is the time for all good men (and <women>) tocometo the aid of theirbeloved country.By the way, I think that <smaller>shouldREALLY be called<tinier>and that I am always right.-- the endwhere the word "beloved" would be in red on a color display if thereceiving software implemented the "x-color" extension.Borenstein [Page 11]Security ConsiderationsSecurity issues are not discussed in this memo, as the mechanismraises no security issues.Author’s AddressFor more information, the author of this document may be contactedvia Internet mail:Nathaniel S. BorensteinMRE 2D-296, Bellcore445 South St.Morristown, NJ 07962-1910Phone: +1 201 829 4270Fax: +1 201 829 5963EMail: nsb@AcknowledgementsThis document reflects the input of many contributors, readers, andimplementors of the original MIME specification, RFC 1341. It alsoreflects particular contributions and comments from Terry Crowley,Rhys Weatherley, and John LoVerso.References[RFC-1341] Borenstein, N., and N. Freed, "MIME (MultipurposeInternet Mail Extensions): Mechanisms for Specifyingand Describing the Format of Internet Message Bodies",RFC 1341, Bellcore, Innosoft, June 1992.[RFC-1521] Borenstein, N., and N. Freed, "MIME (MultipurposeInternet Mail Extensions) Part One: Mechanisms forSpecifying and Describing the Format of InternetMessage Bodies", RFC 1521, Bellcore, Innosoft,September 1993.Borenstein [Page 12]Appendix A -- A Simple enriched-to-plain Translator in COne of the major goals in the design of the text/enriched subtype of the text Content-Type is to make formatted text so simple that eventext-only mailers will implement enriched-to-plain-text translators, thus increasing the likelihood that multifont text will become "safe" to use very widely. To demonstrate this simplicity, what follows is a simple C program that converts text/enriched input into plain text output. Note that the local newline convention (the single character represented by "\n") is assumed by this program, but that specialCRLF handling might be necessary on some systems.#include <stdio.h>#include <ctype.h>main() {int c, i, paramct=0, newlinect=0, nofill=0;char token[62], *p;while ((c=getc(stdin)) != EOF) {if (c == ’<’) {if (newlinect == 1) putc(’ ’, stdout);newlinect = 0;c = getc(stdin);if (c == ’<’) {if (paramct <= 0) putc(c, stdout);} else {ungetc(c, stdin);for (i=0, p=token; (c=getc(stdin)) != EOF && c != ’>’; i++){ if (i < sizeof(token)-1)*p++ = isupper(c) ? tolower(c) : c;}*p = ’\0’;if (c == EOF) break;if (strcmp(token, "param") == 0)paramct++;else if (strcmp(token, "nofill") == 0)nofill++;else if (strcmp(token, "/param") == 0)paramct--;else if (strcmp(token, "/nofill") == 0)nofill--;}} else {if (paramct > 0); /* ignore params */else if (c == ’\n’ && nofill <= 0) {Borenstein [Page 13]if (++newlinect > 1) putc(c, stdout);} else {if (newlinect == 1) putc(’ ’, stdout);newlinect = 0;putc(c, stdout);}}}/* The following line is only needed with line-buffering */putc(’\n’, stdout);exit(0);}It should be noted that one can do considerably better than this indisplaying text/enriched data on a dumb terminal. In particular, one can replace font information such as "bold" with textual emphasis(like *this* or _T_H_I_S_). One can also properly handle thetext/enriched formatting commands regarding indentation,justification, and others. However, the above program is all that is necessary in order to present text/enriched on a dumb terminalwithout showing the user any formatting artifacts.Borenstein [Page 14]Appendix B -- Differences from RFC 1341 text/richtextText/enriched is a clarification, simplification, and refinement ofthe type defined as text/richtext in RFC 1341. For the benefit ofthose who are already familiar with text/richtext, or for those whowant to exploit the similarities to be able to display text/richtext data with their text/enriched software, the differences between thetwo are summarized here. Note, however, that text/enriched isintended to make text/richtext obsolete, so it is not recommendedthat new software generate text/richtext.0. The name "richtext" was changed to "enriched", both todifferentiate the two versions and because "richtext"created widespread confusion with Microsoft’s Rich TextFormat (RTF).1. Clarifications. Many things were ambiguous orunspecified in the text/richtext definition, particularlythe initial state and the semantics of richtext withmultibyte character sets. However, such differences areOPERATIONALLY irrelevant, since the clarifications offeredin this document are at least reasonable interpretations ofthe text/richtext specification.2. Newline semantics have changed. In text/richtext, allCRLFs were mapped to spaces, and line breaks were indicatedby "<nl>". This has been replaced by the "n-1" rule forCRLFs.3. The representation of a literal "<" character was "<lt>"in text/richtext, but is "<<" in text/enriched.4. The "nofill" command did not exist in text/richtext.5. The "param" command did not exist in text/richtext.6. The following commands from text/richtext have beenREMOVED from text/enriched: <COMMENT>, <OUTDENT>,<OUTDENTRIGHT>, <SAMEPAGE>, <SUBSCRIPT>, <SUPERSCRIPT>,<HEADING>, <FOOTING>, <ISO-8859-[1-9]>, <US-ASCII>,<PARAGRAPH>, <SIGNATURE>, <NO-OP>, <LT>, <NL>, and <NP>.7. All claims of SGML compatibility have been dropped.However, with the possible exceptions of the new semanticsfor CRLF and "<<" can be implemented, text/enriched shouldbe no less SGML-friendly than text/richtext was.Borenstein [Page 15]。

相关文档
最新文档