Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 30th, 2012  |  syntax: None  |  size: 1.33 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Perl email script--content encoding issue
  2. #!/usr/bin/perl
  3. use strict;
  4. use warnings;
  5.  
  6. #Character encoding var
  7. my $encoding='text/plain; charset="iso-8859-5"';
  8.  
  9. #Create the message
  10. use Email::MIME;
  11. my $message = Email::MIME->create(
  12.         header_str => [
  13.                 From => 'gmail@gmail.com',
  14.                 To => 'gmail2@gmail.com',
  15.                 Subject => 'I sent you this message using Perl.',
  16.         ],
  17.         body_str => 'I sent you this message using Perl.  One of those languages that would' would've been helpful much sooner in my life...',
  18.         );
  19. use Email::Sender::Simple qw(sendmail);
  20. sendmail($message);
  21.        
  22. body_str was given, but no charset is defined at /usr/local/share/perl/5.10.1/Email/MIME.pm line 243
  23.     Email::MIME::create('Email::MIME', 'header_str', 'ARRAY(0x9a04818)', 'body_str', 'I sent you this message using Perl.  One ...') called at script.pl line 10
  24.        
  25. my $message = Email::MIME->create(
  26.     header_str => [
  27.             From    => 'gmail@gmail.com',
  28.             To      => 'gmail2@gmail.com',
  29.             Subject => 'I sent you this message using Perl.',
  30.     ],
  31.     attributes => {
  32.         encoding => 'quoted-printable',
  33.         charset  => "US-ASCII",
  34.     },
  35.     body_str => 'I sent you this message using Perl.  One of those languages that would' would've been helpful much sooner in my life...',
  36. );