in reply to Re: problem with Mail::Sender while sending email
in thread problem with Mail::Sender while sending email

Please check it. I have modified the code.
#!/usr/bin/perl use Mail::Sender; open(FH,"file.txt"); my $var; while(<FH>) { $var .= $_; } close(FH); eval { Mail::Sender->new( {from => 'from@domain.com', smtp => 'smtp.server.com'}) ->OpenMultipart({ to => '', subject => 'Subject Here!', multipart => 'related', }) ->Part({ ctype => 'text/html', disposition => 'NONE', msg => <<'*END*' $var}) $var *END* ->Attach({ description => 'test file', ctype => 'application/octet-stream', encoding => 'base64', disposition => "attachment; filename= file1 ", file => 'file1' }) ->Close(); } or print "Error sending mail: $Mail::Sender::Error\n";

Replies are listed 'Best First'.
Re^3: problem with Mail::Sender while sending email
by chandanperl (Novice) on Aug 26, 2009 at 05:01 UTC
    Please check this code
    ->Part({ ctype => 'text/html', disposition => 'NONE', msg => <<'*END*'}) $var *END*
      You don't need a heredoc when you have the text in a variable already.

      use this instead
      ->Part({ ctype => 'text/html', disposition => 'NONE', msg => $var})
      Look at this:
      $var = 'hello world'; print <<'END'; $var END
      and this
      $var = 'hello world'; print <<"END" $var END
      Assuming you really do want a 'heredoc' here, you want the second kind.

      Don't put stars in the heredoc terminator, that's ugly. If it doesn't stand out enough already, you need a different editor. END



      - Boldra

        Beauty is in the eye of the beer holder! I use the "*END*" all the time. Not just that it stands out more, but it's also less likely to appear in the stuff I'm quoting. And my editor does highlight the heredocs just fine, thank you.

        Jenda
        Enoch was right!
        Enjoy the last years of Rome.