Hi All,
I am using com.day.cq.mailer.MailService to send email and noticed that whenever I use HTML template it always enclose the template content "pre" tag. My concern is that since it enclose the HTML content into "pre" tag, all my CSS styling is does not reflect because of this. Is there any solution to change this behavior?
My template contains
From: ${fromEmail} Subject: ${subject} <div> <br/> Hi ${toName},<br/> <br/> Your account has been created. To activate your account, please click the following link:<br/><br/> <a href="${link}" >${link}</a><br/><br> Thank You,<br/> ${fromName}<br/> </div>
And the resulting email when it sent
<html><body><pre><div> <br/> Hi homervillanueva,<br/> <br/> Your account has been created. To activate your account, please click the following link:<br/><br/> <a href="http://localhost/register/activate.html?token=24912749237492374" >http://localhost/register/activate.html?token=24912749237492374</a><br/><br> Thank You,<br/> Operation Team<br/> </div></pre></body></html>
Appreciate for any input and advice.
Thanks!
Solved! Go to Solution.
Views
Replies
Total Likes
OOB HtmlEMailTemplate just replace the variables and does not append any elements. Seems like issue at other layer. Verify in the node where template is stored <pre> element exists? If so then look at component may be rte or some custom transformer adding it.
Views
Replies
Total Likes
OOB HtmlEMailTemplate just replace the variables and does not append any elements. Seems like issue at other layer. Verify in the node where template is stored <pre> element exists? If so then look at component may be rte or some custom transformer adding it.
Views
Replies
Total Likes
Hi Sham HC,
The HTML content which I posted above is the actual content of the HTML template i created, nothing more - nothing less. But when the email is sent the whole content of the template is enclosed inside pre, body and html tag. I have no idea where these added tags came from as they were not existing in my template.
Thanks!
Views
Replies
Total Likes
Hi,
Is this solved? I am having the same issue right now but I couldn't find the solution or any possible place inserting the <pre> tag.
Thanks.
Views
Replies
Total Likes
can you paste the code snippet with which you send mail?
Views
Replies
Total Likes
Hi kalyanar,
Please see below:
ArrayList<InternetAddress> emailRecipients = new ArrayList<InternetAddress>(); emailRecipients.add(new InternetAddress(email_address)); Map<String, String> mailTokens = new HashMap<String, String>(); mailTokens.put("xxx", xxx); mailTokens.put("yyy", yyy); HtmlEmail email = new HtmlEmail(); Resource templateRsrc = request.getResourceResolver().getResource(templatePath); final MailTemplate mailTemplate = MailTemplate.create(templateRsrc.getPath(), templateRsrc.getResourceResolver().adaptTo(Session.class)); email = mailTemplate.getEmail(StrLookup.mapLookup(mailTokens), HtmlEmail.class); email.setCharset("UTF-8"); email.setTo(emailRecipients); if (messageGatewayService != null) { messageGateway = messageGatewayService.getGateway(HtmlEmail.class); messageGateway.send(email); }
templatePath link to a html node eg. "/workflow/email/xxx.html", thanks for your reply.
Views
Replies
Total Likes
Hi,
Just in case if anyone need solution, this issue is temporary fixed by wrapping my HTML email content with a "<pre style="white-space:initial"> HTML CONTENT </pre>".
Thanks.
Views
Replies
Total Likes