我有代理发送电子邮件。 我收到mailto,subject和body(以html格式)
我配置axis2.xml 添加
<sequence name="SendMailTransportSequence" trace="disable"
xmlns="http://ws.apache.org/ns/synapse">
<property name="messageType" scope="axis2" value="text/html" />
<property name="ContentType" scope="axis2" value="text/html" />
<property name="OUT_ONLY" scope="default" value="true" />
<property name="FORCE_SC_ACCEPTED" scope="axis2" value="true" />
<!-- SUBJECT -->
<property expression="get-property('mail.asunto')" name="Subject"
scope="transport" />
<!-- TO -->
<property expression="get-property('mail.destinatario')" name="uri.var.dest"
scope="default" type="STRING" />
<header expression="fn:concat('mailto:',get-property('uri.var.dest'))"
name="To" scope="default" />
<!-- BODY -->
<script language="js"><![CDATA[
mc.setPayloadXML(<html><h1>this is the title</h1><br/><p>this is the content................</p></html>);
]]></script>
<send />
</sequence>
和我的序列有效,发送电子邮件,但有一个硬编码的正文:
<script language="js"><![CDATA[
var body = mc.getProperty("mail.cuerpo");
mc.setPayloadXML(<html>{body}</html>);
]]></script>
收到的邮件:
但是,当我试图从一个属性发送身体,我无法达到它
我试试
<script language="js"><![CDATA[
var body = "<h1>this is the title</h1><br/><p>this is the content................</p>";
mc.setPayloadXML(<html>{body}</html>);
]]></script>
并尝试
<payloadFactory media-type="xml">
<format>
<Body>$1</Body>
</format>
<args>
<arg evaluator="xml" expression="get-property('mail.cuerpo')" />
</args>
</payloadFactory>
另一方面,我尝试使用有效负载工厂但没有成功:
在这种情况下,内容会像非附件
一样发送<payloadFactory media-type="xml">
<format>
<ns:text xmlns:ns="http://ws.apache.org/commons/ns/payload">$1</ns:text>
</format>
<args>
<arg evaluator="xml" expression="get-property('mail.cuerpo')" />
</args>
</payloadFactory>
在这种情况下,邮件正文也像纯文本一样被接收
{{1}}
那么,以html格式发送电子邮件的正确形式是什么? 提前谢谢
答案 0 :(得分:4)
在这种情况下,您不能在文本字符串中附加XML元素。所以你必须添加值作为XML子项。因为WSO2 esb使用java脚本rhino。用E4X写。
<form action="" name="search-form" id="search-form" method="get" accept-charset="UTF-8" class="form-vertical">
<div class="city">
<label for="cityId" class="required">Enter your city</label>
<select id="cityId" name="cityId" data-prefill="location.cityId" class="form-control" placeholder="Enter a city">
<option value="88">Vizag</option>
<option value="128">Warangal</option>
<option value="271">Wardha</option>
<option value="252">Yamunanagar</option>
<option value="270">Yavatmal</option>
<option value="303">Yelanka</option>
<option value="207">Zirakpur</option>
</select>
<span id="city-not-selected-error" class="help-inline"></span>
<i class="fa fa-angle-down" aria-hidden="true"></i>
</div>
<div class="purpose">
<label for="purposeId" class="required">Enter Type</label>
<select id="purposeId" name="purposeId" class="form-control" placeholder="Selelct Type">
<option value="select_purpose" selected="selected">Selelct Type</option>
<option value="1" id="gl">Google</option>
<option value="2" id="y">Yahoo</option>
<option value="3" id="fb">Facebook</option>
</select>
<span id="city-not-selected-error" class="help-inline"> </span> <i class="fa fa-angle-down" aria-hidden="true"></i> <span id="purpose-not-selected-error" class="help-inline"> </span>
</div>
<div class="show-ofr">
<input type="submit" name="button" class="btn btn-primary btn-block">
</div>
</form>
&#13;
希望你能从上面的代码中获得想法。如果你想了解更多。请参阅此链接。E4X Quick Start Guide