brian_d_foy helped me understand that issues with the way all the modules Email::Stuff is using talk to one another make it necessary to pass through LocalHost and LocalPort variables in order to send mail via GMail:

"The problem is the long chain of modules with slightly different interfaces. I haven't narrowed it down, but somebody isn't setting LocalAddr and LocalPort, so when you try to configure things, IO::Socket::configure fails because IO::Socket::_sock_info fails since nothing set those hash entries:"

($laddr,$lport,$proto) = _sock_info($arg->{LocalAddr}, $arg->{LocalPort}, $arg->{Proto}) or return _error($sock, $!, $@);

So my solution ended up looking like this:

#!/usr/bin/perl use warnings; use strict; use Email::Stuff; my $LocalHost = 'jasmines.mikebaas.org'; my $LocalPort = '2525'; my $RemoteHost = 'smtp.gmail.com'; my $RemotePort = '465'; my $objst = Email::Stuff ->to($ARGV[0]) ->from($ARGV[1]) ->subject($ARGV[2]) ->text_body($ARGV[3]) ; $objst->send( 'SMTP', ssl => 1, Host => $RemoteHost, Port => $RemotePort, Proto => 'tcp', username => $ARGV[4], password => $ARGV[5], Debug => 1, LocalAddr => $LocalHost, LocalPort => $LocalPort, );

However, I cannot send emails one after the other in serial since the localport 2525 binds to 465 and doesn't let go. As far as I can see, there is no way to send a QUIT via Email::Stuff. If there were, I could create one connection per each email I wish to send via Gmail.

I've also tried sleeping in between each message but because that always seemed to produce random results. So I'm closer but not out of the woods yet.


In reply to Re: Using Email::Stuff to send SMTP mail through GMail by initself
in thread Using Email::Stuff to send SMTP mail through GMail by initself

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.