我无法让Mule发送HTML格式的电子邮件 [英] I cannot get Mule to send an HTML formatted email

查看:103
本文介绍了我无法让Mule发送HTML格式的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了所有我能想到的字符串到字节数组转换器,没有字符串到字节数组转换器,我仍然以纯文本格式发送电子邮件。

这里是我的Gmail版本,当我显示原始消息:

主题:为什么没有标记?
MIME-Version:1.0
Content-Type: text / plain; charset =us-ascii
Content-Transfer-Encoding:7bit
返回路径:rufus@abc.com

 < html>< head>< meta http-equiv =Content < / head>< / head>< / body>< / body>>< 

请大家指出我做错了什么。

谢谢,Don

以下是一个简单的测试用例:


  < mule xmlns:scripting =http://www.mulesoft.org/schema/mule/scriptingxmlns:smtp =http://www.mulesoft.org/schema/mule/smtpxmlns:quartz = http://www.mulesoft.org/schema/mule/quartz
xmlns =http://www.mulesoft.org/schema/mule/corexmlns:doc =http:// www。 mulesoft.org/schema/mule/documentationxmlns:spring =http://www.springframework.org/schema/beans
version =EE-3.5.0xmlns:xsi =http:/ /www.w3.org/2001/XMLSchema-instance
xsi:schemaLocation =
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org /schema/mule/scripting/current/mule-scripting.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule .xsd
http://www.mulesoft.org/schema/mule/smtp http://www.mulesoft.org/schema/mule/smtp/current/mule-smtp.xsd
http: //www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/current/mule-quartz.xsd\">
< flow name =htmlemailtestFlow1doc:name =htmlemailtestFlow1>
< quartz:event-generator-job />
< / quartz:inbound-endpoint>
< scripting:script engine =Groovy>
< / scripting:script>
< / scripting:component>
responseTimeout =10000doc:name =AsnEmailmimeType =text / html/>
< / flow>
< / mule>


解决方案

连接器上的contentType:

 < smtp:connector name =smtp
validateConnections =truecontentType =text / html/>


I have tried all I can think of string-to-byte-array-transformer, no string-to-byte-array-transformer, and I still get the email sent in plain/text format.
Here is my gmail version when I show original message:
Subject: Why no markup? MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-Path: rufus@abc.com

<html><head><meta http-equiv="Content-Type" content="text/html" charset="us-ascii"/></head><body><p>An HTML paragraph</p></body></html>  

Please shine a light on what I am doing wrong.
Thanks, Don

Below is a simple test case:

<mule xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" xmlns:smtp="http://www.mulesoft.org/schema/mule/smtp" xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz"
    xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans"
    version="EE-3.5.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/smtp http://www.mulesoft.org/schema/mule/smtp/current/mule-smtp.xsd
http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/current/mule-quartz.xsd">
    <flow name="htmlemailtestFlow1" doc:name="htmlemailtestFlow1">
        <quartz:inbound-endpoint jobName="Q1" repeatInterval="60000" responseTimeout="10000" doc:name="Quartz">
            <quartz:event-generator-job />
        </quartz:inbound-endpoint>
        <scripting:component doc:name="Groovy">
            <scripting:script engine="Groovy">
                <scripting:text><![CDATA[return '<html><head><meta http-equiv="Content-Type" content="text/html" charset="us-ascii"/></head><body><p>An HTML paragraph</p></body></html>']]></scripting:text>
            </scripting:script>
        </scripting:component>
        <string-to-byte-array-transformer mimeType="text/html" doc:name="String to Byte Array" />
        <smtp:outbound-endpoint host="mail.abc.com" to="dharrington@abc.com" from="rufus@abc.com" subject="Why no markup?"
            responseTimeout="10000" doc:name="AsnEmail" mimeType="text/html" />
    </flow>
</mule>

解决方案

Se the contentType on the connector:

<smtp:connector name="smtp"
        validateConnections="true" contentType="text/html"  />

这篇关于我无法让Mule发送HTML格式的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆