User Tools

Site Tools


MIME::Lite sample

mail.pl
#!/usr/bin/env perl
 
use strict;
use MIME::Lite;
use MIME::Base64 qw(encode_base64);
use Encode qw(decode encode);
 
my $from = 'some@sender.org';
my $to = 'some@bare.com';
my $subject = 'Hello Привет';
 
$msg = MIME::Lite->new(
        From     => $from,
        To       => $to,
        Subject  => "=?UTF-8?B?" . encode_base64($subject, "") . "?=",
        Type     => 'multipart/mixed',
);
 
$msg->attach(
      Type     => 'text/plain; charset=UTF-8', 
      Data     => "Привет! The attachment contains your file"
);
 
#$msg->print(\*STDOUT);
#$msg->print_header(\*STDOUT);
#$msg->print_body(\*STDOUT);
 
my $server = "mx8.lazurit.com";
 
#$msg->send; 
$msg->send('smtp', $server, Timeout => 60, Debug => 1);
print "Mail Sent\n";
 
#EOF

First PagePrevious PageBack to overviewNext PageLast Page