首页 > 解决方案 > wso2 JMS JSON 到没有肥皂信封或非 xml html 的 html 电子邮件

问题描述

我想从 JMS JSON 消息中使用 wso2 4.9.0 发送一个适当的完全动态(到、从、正文、主题)html 电子邮件。

这是我想要的 SMTP 交换,其中所有值都来自 json 消息:

From: foo <noreply@bar>
Reply-To: foo <noreply@bar>
To: foobar@bar
Cc: bar@bar
Subject: =?UTF8?Q?test;_eacute:_=C3=A9?=
MIME-Version: 1.0
Content-Type: text/html; charset=UTF8
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE html><html><body>Hello =C3=A9<br> and a=
long line is split before 76 chars</body></html>

我试过(为了清楚起见缩写):

mc.setPayloadXML(<ns:text xmlns:ns="http://ws.apache.org/commons/ns/payload">{message}</ns:text>);
// Almost OK but with 4.9.0, the PlainTextFormatter forces the Content-Type to text/plain (I think this is solved in wso2esb 5+)

我也试过:

//Using in axis2.xml :  <messageFormatter contentType="text/html" class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>  
mc.setPayloadXML(<html><body>{message}</body></html>)
// Not ok: Escapes the message
// if it didn't escape the message, it would result in invalid xml anyway

我还尝试了十几种其他组合,但都没有奏效。

是否可以接收 JSON JMS 消息,对其进行解析并从值发送正确的 html 电子邮件?

标签: jsonemailwso2jmswso2esb

解决方案


以下步骤将帮助您实现您的要求

  1. 一旦 JSON 消息被读入 ESB,它将是 SOAP 格式。因此,使用 xslt 调解器将内容更改为您想要的输出 html
  2. 将 messageType 和 ContentType 设置为 text/html
  3. 在 /repository/conf/axis2/axis2.xml 中启用 text/html 消息格式化程序

  4. 发送电子邮件

此博客包含使用上述方法的电子邮件功能示例实现 https://medium.com/@Jenananthan/wso2-esb-sending-email-notification-2150f8dca2aa


推荐阅读