Thanks all for your valuable suggestions. @Rick below is the error that I got when I tried the code that I mentioned in the first post.
[testemail:37988] error @2016-01-26 14:46:09> Route exception: Could not send email can't build entity: no body, and not multipart I am getting a multipart warning because I didn't specify "multipart => 'related'" in email function. I believe, Dancer2 requires "multipart" to be set to "related" when you want to send HTML emails. I might be wrong but that's what I experienced so far. Best, Tushar On Thu, Jan 28, 2016 at 7:00 AM, <[email protected]> wrote: > Send dancer-users mailing list submissions to > [email protected] > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.preshweb.co.uk/mailman/listinfo/dancer-users > or, via email, send a message with subject or body 'help' to > [email protected] > > You can reach the person managing the list at > [email protected] > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of dancer-users digest..." > > > Today's Topics: > > 1. Re: (Rick Leir) > 2. Re: How to use HTML template as body to an Email? (Kadir Beyazl?) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Wed, 27 Jan 2016 09:45:56 -0500 > From: Rick Leir <[email protected]> > To: [email protected] > Subject: Re: [dancer-users] How to use HTML template as body to an > Email? > Message-ID: > < > cagitpvzpwjx055p8q-w9pmet9dyztfp83rmk_oczg04psou...@mail.gmail.com> > Content-Type: text/plain; charset="utf-8" > > There were threads on this recently, I posted config, Perl and tt. There > are a few gotchas but it is quite do-able. What error do you see? > > http://lists.preshweb.co.uk/pipermail/dancer-users/2016-January/005429.html > http://lists.preshweb.co.uk/pipermail/dancer-users/2016-January/005448.html > cheers -- Rick > > > > 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 => '[email protected]', > > to => '[email protected]', > > subject => 'test email', > > body => template 'contactUsEmail.tt', {name => $params->{'name'}, > > email => $params->email'}, message => $params->{'message'}}, > > type => 'html' > > }; > > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20160127/51866dee/attachment-0001.html > > > > ------------------------------ > > Message: 2 > Date: Wed, 27 Jan 2016 16:52:29 +0200 > From: Kadir Beyazl? <[email protected]> > To: Perl Dancer users mailing list <[email protected]> > Subject: Re: [dancer-users] How to use HTML template as body to an > Email? > Message-ID: > < > cacrdqbvfew3qifr9e-sbj8+47ne2bd8pzrgbduejuzrgxpe...@mail.gmail.com> > Content-Type: text/plain; charset=UTF-8 > > On Tue, Jan 26, 2016 at 8:57 PM, Tushar Dave <[email protected]> > wrote: > > 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 => '[email protected]', > > to => '[email protected]', > > subject => 'test email', > > body => template 'contactUsEmail.tt', {name => $params->{'name'}, > > email => $params->email'}, message => $params->{'message'}}, > > type => 'html' > > }; > > } catch { > > error "Could not send email: $_"; > > }; > [KB] You can use it as follow: > > my $body = template 'contactUsEmail.tt', {name => $params->{'name'}, > email => $params->email'}, message => $params->{'message'}}, { layout > => undef }; > > try { > email { > from => '[email protected]', > to => '[email protected]', > subject => 'test email', > body => $body, > 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 > > code.."). > > > > Thanks for the help. > > > > Best, > > Tushar Dave > > > > > > _______________________________________________ > > dancer-users mailing list > > [email protected] > > http://lists.preshweb.co.uk/mailman/listinfo/dancer-users > > > > > > -- > Kadir Beyazl? > Computer Engineer > GSM : +90 535 821 50 00 > > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > dancer-users mailing list > [email protected] > http://lists.preshweb.co.uk/mailman/listinfo/dancer-users > > > ------------------------------ > > End of dancer-users Digest, Vol 71, Issue 17 > ******************************************** > -- Tushar Dave
_______________________________________________ dancer-users mailing list [email protected] http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
