Sending formatted mails with Mule

后端 未结 2 1002
一生所求
一生所求 2021-01-15 04:30

I\'m sending emails using Mule. I need to add format to the text I send. The content of the mail is the payload which has a String in it that I form in a Java method and sen

相关标签:
2条回答
  • 2021-01-15 04:50

    I solved it. I was missing setting content-type in the smtp:connector and the mime-type in the smtp:outbpund-endbound as text/html for the to work. This is the correct code:

    <smtp:connector name="smtpConnector"
        validateConnections="true" doc:name="SMTP" contentType="text/html"/>
     <smtp:outbound-endpoint host="${smtp.host}"
        responseTimeout="10000" doc:name="SMTP" connector-ref="smtpConnector"
        from="${smtp.from}" port="${smtp.port}" subject="Invoice"
        to="mail@mail.com"" mimeType="text/html"/>
    

    With this configuration you can use html in your text like this

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"><head><title>Email</title></head><body style="font-family:'Century Gothic'"><h1 style="text-align:center;"> company </h1><h2 style="font-size:14px;">Name : name <br />Company : arch <br />Email : qqq@aaaa.com</h2><p>fin</p></body></html>
    

    and it will be shown when receiving the email.

    Hope it'll help someone else.

    0 讨论(0)
  • 2021-01-15 05:01

    Alternately you can use a Velocity template with your Mule application.
    Velocity is a Java-based template engine and can be used to send formatted email.
    You can also use various HTML tags to format your content
    ref :- https://velocity.apache.org/engine/releases/velocity-1.5/user-guide.html

    0 讨论(0)
提交回复
热议问题