Re: [dancer-users] How to use HTML template as body to an Email?
I have not been using multipart so far, though I may do in the future. HTH. use Email::MIME::CreateHTML; use Email::Sender::Simple qw(sendmail); use Email::Sender::Transport::SMTP qw(); ... my $email_body = template( $tt, \%fields, ); # produce an Email::Abstract compatible message object, my $email = Email::MIME->create_html( header => [ From => $fields{email_from}, To => $fields{email}, Subject => $fields{email_subject}, ], body => $email_body, ); try { sendmail($email, { from => $fields{email_from}, transport => Email::Sender::Transport::SMTP->new({ host => config->{smtp_server}, port => config->{smtp_port}, }), } ); } catch { .. [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.
participants (1)
-
Rick Leir