On Wed, Feb 20, 2013 at 10:41:51AM -0800, Rajeev Prasad wrote:
> hello follwoing code is sending empty email body. I am trying
> to send HTML content in body of mesg. It works if I use a
> string instead of array. I tried sending reference to
> @email_body, but It simply printed array_ref in body.
> 
> open(my $tmp_fh,"<",html_file) or die "error: $!";

I will assume that html_file is supposed to be a bareword. :-/

>     @email_body = <$tmp_fh>;
> close $tmp_fh;

See also File::Slurp, which would eliminate this "problem" with
less code than open, <>, close, and join:

use File::Slurp qw/slurp/;

my $email_body = slurp(html_file);

>     my $message = Email::MIME->create(
>       header_str => [
>         From    => '<jo...@apple.com>',
>         To      => '<jac...@banana.com>',
>         Subject => "Please see my test email",
>       ],
>       attributes => {
>         encoding => 'quoted-printable',
>         charset  => 'ISO-8859-1',
>         content_type => 'text/html'
>       },
>       body_str => @email_body,

        body_str => $email_body,

>     );
> 
>     sendmail($message);

Regards,


-- 
Brandon McCaig <bamcc...@gmail.com> <bamcc...@castopulence.org>
Castopulence Software <https://www.castopulence.org/>
Blog <http://www.bamccaig.com/>
perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }.
q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.};
tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say'

Attachment: signature.asc
Description: Digital signature

Reply via email to