如何从 Kynetx 电子邮件端点访问消息正文?
我想从入站电子邮件中提取 URL,然后使用 http:get() 提取 URL。如何访问消息正文?
select when mail received from "(.*)@example.com" setting user
pre { /* extract first URL from message */ }
http:get(URL);
那么,考虑到以下电子邮件消息,PRE 块中会发生什么:
From: Example User <[email protected]>
To: x202 Endpoint <[email protected]>
Subject: An interesting URL
http://www.example.net
I want to extract a URL from an inbound email message and then http:get() the URL. How can I access the message body?
select when mail received from "(.*)@example.com" setting user
pre { /* extract first URL from message */ }
http:get(URL);
So what goes in the PRE block, given the following email message:
From: Example User <[email protected]>
To: x202 Endpoint <[email protected]>
Subject: An interesting URL
http://www.example.net
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
email:parts()
方法提取电子邮件的各个部分。在多部分电子邮件中,您将同时拥有 text/html 和 text/plain 部分。要访问电子邮件,您首先从
msg
事件参数中提取电子邮件(采用 RFC822 形式),如下所示:然后,您可以使用 parts 方法提取一部分。此代码示例提取电子邮件的纯文本部分:
在不传递 mime 过滤器的情况下调用
email:parts(envelope)
将返回包含电子邮件所有部分的结构。获得正文后,您可以使用
textportion.extract(re//)
从电子邮件正文中提取信息。You use the
email:parts()
method to extract the portions of the email. In a multipart email, you will have both text/html and text/plain parts.To access the email, you first extract the email (in RFC822 form) from the
msg
event param, like so:Then, you can use the parts method to extract a portion. This code example extracts the plain text portion of the email:
Calling
email:parts(envelope)
without passing a mime filter will return a struct with all the parts of the email.Once you have the body, you can use
textportion.extract(re//)
to extract information from the email body.