[Chicago-talk] Sending an email via gmail using MIME::Lite

Jay Strauss me at heyjay.com
Sat Dec 13 05:30:45 PST 2008

Hi, I would have thought this would be well worn territory on google,
but I could not find out how to do this.  Maybe its so elementary no
one posted an example.

I can seem to send an email via MIME::Lite using gmail's smtp.  Here
is what I have and get:


use strict;
use MIME::Lite;

my $smtp_server = "smtp.gmail.com";
my $smtp_port   = 465;
my $debug       = 1;
my $user        = "user";
my $passwd      = "password";

MIME::Lite->send('smtp', $smtp_server ,
                          Port =>$smtp_port ,
                          Timeout=>60 ,
                          Debug => $debug ,
                          Hello => 'domain.com',
                          User  => $user,
                          Password  => $passwd);

my $msg = MIME::Lite->new(
        From    =>'jay at duetloans.com',
        To      =>'me at heyjay.com',
        Subject =>'This is a test',
        Data    =>"this is the body"


When I run it:
jstrauss at neon:~/bin$ email.pl
MIME::Lite::SMTP>>> MIME::Lite::SMTP
MIME::Lite::SMTP>>>   Net::SMTP(2.29)
MIME::Lite::SMTP>>>     Net::Cmd(2.26)
MIME::Lite::SMTP>>>       Exporter(5.58)
MIME::Lite::SMTP>>>     IO::Socket::INET(1.29)
MIME::Lite::SMTP>>>       IO::Socket(1.29)
MIME::Lite::SMTP>>>         IO::Handle(1.25)
MIME::Lite::SMTP=GLOB(0x83c9fd4): Timeout at
/usr/share/perl5/MIME/Lite.pm line 2634
Failed to connect to mail server: Bad file descriptor
 at /home/jstrauss/bin/email.pl line 27

I feel its probably not connecting properly, but I don't see what to do.

More information about the Chicago-talk mailing list