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?

In reply to Mac OS X and Email::Send::Gmail by smithca2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.