[dancer-users] How to use HTML template as body to an Email?

Tushar Dave tushardave26 at gmail.com
Tue Jan 26 18:57:28 GMT 2016

Hello Fellow Dancers,

I am trying to send an email as HTML using HTML template. Does anybody know
that how can I use HTML template (that resides in view directory) as email
body? So far I tried the following code but am not able to get it working.
It may be not the right way of doing it.

try {
    email {
        from => 'abc at xyz.com',
        to => 'xyz at abc.com',
        subject => 'test email',
        body => template 'contactUsEmail.tt', {name => $params->{'name'},
email => $params->email'}, message => $params->{'message'}},
        type => 'html'
} catch {
    error "Could not send email: $_";

Another possible solution that I am thinking of, I can just store the
entire HTML code in a scalar variable and use it as email body (e.g. body
 => $template, where $tempalte contains the HTML code as $template ="html

Thanks for the help.

Tushar Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20160126/d3ad0284/attachment.html>

More information about the dancer-users mailing list