2009年1月9日星期五

html2blogger

#!/usr/bin/perl 
use Email::Send;

my $mailer = Email::Send->new( {
mailer => 'SMTP::TLS', ## thanks fayland constantly
mailer_args => [
Host => 'smtp.gmail.com',
Port => 587,
User => 'joe.jiang@gmail.com',
Password => 'noPassAtAll',
Hello => 'cpan.3322.org', # sorry 4 minicpan mirror stopped
]
} );

use Email::MIME::Creator; # or other Email::
use IO::All;

my @parts = (
Email::MIME->create(
attributes=>{
filename=>qq(oracle.html), # it's a not bad name at least
content_type=>qq(text/html),
encoding=>qq(base64)
},
body=>join("",) # read html from stdin
));

my $email = Email::MIME->create(
header => [
From => 'joe.jiang@gmail.com',
To => 'his.helper@hotmail.com', # CC my wife
Subject => shift @ARGV,
Bcc => join qq(, ), @ARGV,
],
parts => [@parts]
);

eval { $mailer->send($email) };
die "Error sending email: $@" if $@; # actually nerver happen

# unless mail too big to encode in base64, need to split it


没有评论: