#!/usr/bin/perl use strict; use warnings; use Net::SMTPS; use CGI::Carp qw(fatalsToBrowser); use English '-no_match_vars'; our @ARGV = ( 'me_at@gmail.com', 'mypassword', 'tosombody@forumsoftwar +e.com', 'me_at@gmail.com' ); my $body = "Test message"; my $headers = "Content-Type: text/plain\r\n\r\n"; my $smtp_server = 'smtp.gmail.com'; my $port = 587; my $ssl = 'starttls'; # 'ssl' / 'starttls' / undef my $mailer = new Net::SMTPS( $smtp_server, Hello => 'host.mydomain.net', Port => $port, Debug => 1, doSSL => $ssl, ) || die "Unable to create Net::SMTPS object. Server: '$smtp_serve +r', port '$port'\n\n" . $OS_ERROR; $mailer->auth($ARGV[0], $ARGV[1]); $mailer->mail($ARGV[3]); $mailer->to($ARGV[2]); $mailer->data(); $mailer->datasend("Subject: SMTP test\r\n\r\n" . $headers . $body); $mailer->dataend; $mailer->quit; print "Content-type: text/html\n\n" or croak 'cannot print line1'; print "Complete"; exit();

Okay - the above works (and it's not Net::SMTP::TLS). Yes, I know Net::SMTPS is also old and deprecated BUT I found another complication last night. CPanel still ships with Perl 5.8.8 so my code has to work with Perl 5.8.8

Another annoyance - The docs for Net::SMTP 3.03 say this:

B<Port> - port to connect to. Default - 25 for plain SMTP and 465 for immediate SSL. B<SSL> - If the connection should be done from start with SSL, contrar +y to later upgrade with C<starttls>. You can use SSL arguments as documented in L<IO::Socket::SSL>, but it +will usually use the right arguments already.
But that requires at least IO::Socket::SSL 2.007 and that is well above the version 1.79 that Perl 5.8.8 seems to support. Or at least above the version that I can get CPanel to install.

So, any hints on how to explicitly tell Net::SMTP 3.03 that it's supposed to tell IO::Socket::SSL 1.79 to start starttls.


In reply to Re^3: Net::SMTP::SSL ACK!! by Dandello
in thread Net::SMTP::SSL ACK!! by Dandello

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.