next2u next2u - 4 months ago 41
PHP Question

how to read template using swift mailer?

I have a

template file(html file)
. I have to include this template in my mail. How can i read template using
swift mailer
.

I tried

$emailBody = readTemplateFile("http://www.something.in/guitar-mail.html");
$emailBody_new = str_replace("#name#",$reg_fname,$emailBody);
$emailBody_new = str_replace("#email#",$url,$emailBody_new);
$message->setBody($emailBody_new);


But in mail the
html
tags and
css
are displayed as plane text. How can i did this??

Answer

Ok, finally i got the solution..

replace the line

$message->setBody($emailBody_new);

with this

$message->setBody($emailBody_new, "text/html");

This worked..