[dancer-users] How to use HTML template as body to an Email?
Tushar Dave
tushardave26 at gmail.com
Thu Jan 28 13:45:49 GMT 2016
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, <dancer-users-request at dancer.pm> wrote:
> Send dancer-users mailing list submissions to
> dancer-users at dancer.pm
>
> 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
> dancer-users-request at dancer.pm
>
> You can reach the person managing the list at
> dancer-users-owner at dancer.pm
>
> 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 <richard.leir at canadiana.ca>
> To: dancer-users at dancer.pm
> Subject: Re: [dancer-users] How to use HTML template as body to an
> Email?
> Message-ID:
> <
> CAGitpvZpWJx055P8Q-W9pMet9DYztFp83rMK_OCzg04pSouNMA at 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 => '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'
> > };
> >
> -------------- 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? <kadirbeyazli at gmail.com>
> To: Perl Dancer users mailing list <dancer-users at dancer.pm>
> Subject: Re: [dancer-users] How to use HTML template as body to an
> Email?
> Message-ID:
> <
> CACRdqbVFew3qiFr9E-sBJ8+47nE2bD8PzrgbDuejUZRGXpEUwg at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> On Tue, Jan 26, 2016 at 8:57 PM, Tushar Dave <tushardave26 at gmail.com>
> 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 => '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: $_";
> > };
> [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 => 'abc at xyz.com',
> to => 'xyz at abc.com',
> 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
> > dancer-users at dancer.pm
> > 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
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>
>
> ------------------------------
>
> End of dancer-users Digest, Vol 71, Issue 17
> ********************************************
>
--
Tushar Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20160128/a6bd3b5e/attachment.html>
More information about the dancer-users
mailing list