Diary SiteMap RecentChanges About Contact 2009-06 Calendar

Search:

Matching Pages:

2009-06-06 Spam Makes Sending Mail Harder

Here I am trying to send mail using some Perl module. But most of them seem to be written for the last millenium. They work best with a local SMTP host. For my own needs, that no longer works. The webhost doesn’t have a sendmail binary available. The SMTP hosts I can reach require SSL and TLS authentication. Now I’m slowly digging into MIME::Entity, Mail::Internet, Mail::Mailer, Net::SMTP, Net::SMTP::SSL, Net::SMTP::TLS… :( sucks

After experimenting with the four or five mail accounts I have access to, I was finally able to get the following to work:

my $from = 'kensanata@gmail.com';
my $to = $from;
my $host = 'mail.epfarms.org';
my $user = 'alex';
my $password = '*secret*';

use MIME::Entity;
my $mail = new MIME::Entity->build(To => $to,
				   From => $from,
				   Subject => 'test',
				   Path => '/Users/alex/test.html',
				   Type => 'text/html');

use Net::SMTP::TLS;
my $smtp = Net::SMTP::TLS->new($host,
			       User => $user,
			       Password => $password,
			       Debug => 1);
$smtp->mail($from); # sender
$smtp->to($to);     # recipient
$smtp->data;
$smtp->datasend($mail->stringify);
$smtp->dataend;
$smtp->quit;

Tags:

Read Comments (3)

Show Google +1