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
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.
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