Mule - 个性化正文 SMTP 组件
Mule - Personalize Body SMTP Component
我有一个 mule flow
执行以下操作:
HTTP
=> JSON to XML
=> XSLT
=> Logger
=> SMTP
我想将正文个性化到包含message.payload
和我的个人文本的电子邮件,例如:
It has received an XML message with the following information:
#[message.payloadAs(java.lang.String)]
message.payload
是XML
转换成XSLT component
,收到的邮件如下:
It has received an XML message with the following information:
author:Gambardella, Matthew
我需要什么才能用我的文字个性化消息?
我应该使用 payload component
还是 property
?
SMTP 连接器将使用负载作为邮件正文,因此只需在负载中设置您要发送的内容即可,例如:
<set-payload value="It has received an XML message with the following information: #[message.payloadAs(java.lang.String)]" doc:name="Set Payload"/>
现在,如果您想发送此电子邮件有 HTML 封邮件,那么您可以在您的负载中添加 html 标签甚至样式,您可以通过向 SMTP 添加一个全局连接器和在全局连接器上设置 contentType,请注意仅在 SMTP 端点上直接设置 mimeType 不会生效:
<smtp:connector name="SMTP_exception_mailer" contentType="text/html" validateConnections="true" doc:name="SMTP"/>
<smtp:outbound-endpoint host="host" port="25" connector-ref="SMTP_exception_mailer" to="you@me.com" from="system@mule" mimeType="text/html" doc:name="SMTP"/>
复杂 HTML 邮件的额外提示
如果你想发送复杂的 html 邮件,很明显使用 set-payload 组件会很复杂,一个好的选择是使用 parse template component,这将允许你将您的 html 写入外部文件,同时使用其中的 MEL 表达式。
我有一个 mule flow
执行以下操作:
HTTP
=> JSON to XML
=> XSLT
=> Logger
=> SMTP
我想将正文个性化到包含message.payload
和我的个人文本的电子邮件,例如:
It has received an XML message with the following information:
#[message.payloadAs(java.lang.String)]
message.payload
是XML
转换成XSLT component
,收到的邮件如下:
It has received an XML message with the following information:
author:Gambardella, Matthew
我需要什么才能用我的文字个性化消息?
我应该使用 payload component
还是 property
?
SMTP 连接器将使用负载作为邮件正文,因此只需在负载中设置您要发送的内容即可,例如:
<set-payload value="It has received an XML message with the following information: #[message.payloadAs(java.lang.String)]" doc:name="Set Payload"/>
现在,如果您想发送此电子邮件有 HTML 封邮件,那么您可以在您的负载中添加 html 标签甚至样式,您可以通过向 SMTP 添加一个全局连接器和在全局连接器上设置 contentType,请注意仅在 SMTP 端点上直接设置 mimeType 不会生效:
<smtp:connector name="SMTP_exception_mailer" contentType="text/html" validateConnections="true" doc:name="SMTP"/>
<smtp:outbound-endpoint host="host" port="25" connector-ref="SMTP_exception_mailer" to="you@me.com" from="system@mule" mimeType="text/html" doc:name="SMTP"/>
复杂 HTML 邮件的额外提示
如果你想发送复杂的 html 邮件,很明显使用 set-payload 组件会很复杂,一个好的选择是使用 parse template component,这将允许你将您的 html 写入外部文件,同时使用其中的 MEL 表达式。