smithca2 has asked for the wisdom of the Perl Monks concerning the following question:

I have installed Email:Send::Gmail on my Mac that is running OS 10.5.8 by running

 sudo perl -MCPAN -e 'install Email::Send::Gmail'

I tried running the example script:
#!/usr/bin/perl use strict; use warnings; use Email::Send; use Email::Send::Gmail; use Email::Simple::Creator; my $email = Email::Simple->create( header => [ From => 'XXXXXXXX@gmail.com', To => 'XXXXXXXX@yahoo.com', Subject => 'test msg', ], body => 'Test msg body', ); my $sender = Email::Send->new( { mailer => 'Gmail', mailer_args => [ username => 'XXXXXXXX@gmail.com', password => 'XXXXXXXX', ] } ); eval { $sender->send($email) }; die "Error sending email: $@" if $@;
with the XXXXX sections changed to match my account, but I get this error:

Error sending email: Email::Send::Gmail: error connecting to server smtp.gmail.com at /Library/Perl/5.8.8/Email/Send.pm line 253

I've run the code in the perl debugger and this is the stack trace at the time of the error:

$ = IO::Socket::INET::_error(ref(Net::SMTP::SSL), '', '') called from +file `/System/Library/Perl/5.8.8/IO/Socket/INET.pm' line 111<br> $ = IO::Socket::INET::configure(ref(Net::SMTP::SSL), ref(HASH)) called + from file `/System/Library/Perl/Extras/5.8.8/IO/Socket/SSL.pm' line +97<br> $ = IO::Socket::SSL::configure(ref(Net::SMTP::SSL), ref(HASH)) called +from file `/System/Library/Perl/5.8.8/darwin-thread-multi-2level/IO/S +ocket.pm' line 48<br> $ = IO::Socket::new('Net::SMTP::SSL', 'PeerAddr', 'smtp.gmail.com', 'P +eerPort', 465, 'LocalAddr', undef, 'LocalPort', undef, 'Proto', 'tcp' +, 'Timeout', 120) called from file `/System/Library/Perl/5.8.8/IO/Soc +ket/INET.pm' line 32<br> $ = IO::Socket::INET::new('Net::SMTP::SSL', 'PeerAddr', 'smtp.gmail.co +m', 'PeerPort', 465, 'LocalAddr', undef, 'LocalPort', undef, 'Proto', + 'tcp', 'Timeout', 120) called from file `/Library/Perl/Updates/5.8.8 +/Net/SMTP.pm' line 41<br> $ = Net::SMTP::new('Net::SMTP::SSL', 'smtp.gmail.com', 'Port', 465, 'D +ebug', 0) called from file `/Library/Perl/5.8.8/Email/Send/Gmail.pm' +line 37<br> . = Email::Send::Gmail::send('Email::Send::Gmail', ref(Email::Simple), + 'username', 'XXXXXXXX@gmail.com', 'password', 'XXXXXXXX') called fro +m file `/Library/Perl/5.8.8/Email/Send.pm' line 253<br> . = Email::Send::_send_it(ref(Email::Send), 'Gmail', ref(Email::Simple +)) called from file `/Library/Perl/5.8.8/Email/Send.pm' line 167<br> . = Email::Send::send(ref(Email::Send), ref(Email::Simple)) called fro +m file `./s2.pl' line 26<br> . = eval {...} called from file `./s2.pl' line 26<p></p>

The error seems to stem from calling IO::Socket::SSL:configure with LocalAddr and LocalPort both with values of ''. Gmail::send only populates PeerAddr, PeerPort and Proto. The versions of files I'm running are these:

SSL.pm version = 0.999<br> Socket.pm version = 1.29<br> INET.pm version = 1.29<br> SMTP.pm version = 2.31 <br> Gmail.pm version = 0.33<br> Send.pm version = 2.198<br>

Do I need to force population of LocalAddr and LocalPort? Do I have a bad mix of file versions? Am I just doing something dumb?

Replies are listed 'Best First'.
Re: Mac OS X and Email::Send::Gmail
by Anonymous Monk on Jun 01, 2010 at 06:56 UTC
    Do I need to force population of LocalAddr and LocalPort?

    No.

    Do I have a bad mix of file versions?

    They look outdated, so that could be the cause, you should upgrade.

    Am I just doing something dumb?

    Unlikely

      Hello smithca2, were you able to resolve this problem? I'm currently facing the same issue. A test script runs fine on Linux, but fails with the same error on Mac OS X 10.5.8.