I am trying to use Amazon's SES (simple email service) via SMTP. This should be a pretty simple straight forward thing to set up (which I have done with other similar services such as http://www.authsmtp.com).

Of course, I am running into problems. I have tried Mail::Sender but it is just hanging. SES uses nonstandard port of 465 but I am able to define that. I am able to connect from the command line:

# telnet email-smtp.us-east-1.amazonaws.com 465 Trying 107.20.160.81... Connected to email-smtp.us-east-1.amazonaws.com. Escape character is '^]'. HELO adsf Connection closed by foreign host.
SES says it requires TLS with SMTP. Mail::Sender doesn't seem to have support for this built in. So, I tried Email::Send::SMTP::TLS, but I am getting similar problems.

Both packages just hang when trying to connect to the remote server for a minute or two and then disconnect with "connection not established" (Mail::Sender) or "Could not connect to SMTP server" (Email::Send::SMTP::TLS).

Here is what I am doing with Mail::Sender (I tried all the auth methods it supports with no luck):

open my $DEBUG, ">>smtp_log" or print STDERR "Unable to open smtp_log" +; ## Send an email my $sender = new Mail::Sender { from => $from, smtp => $server, port => '465', auth => 'login', authid => $username, authpwd => $password, debug => $DEBUG, debug_level => 4, } or print STDERR "Can't create Mail::Sender object: $Mail::Sender::Er +ror\n"; $Mail::Sender::NO_X_MAILER = 1; $sender->Open({ to => $to, subject => "Test Email", ctype => 'text/plain', encoding => "quoted-printable", }) or print STDERR "Can't open the message: $sender->{'error_msg'}\n"; my $msg = "This is a test email with Mail::Sender\n\n"; $sender->SendEnc($msg); close $DEBUG;
And Email::Send::SMTP::TLS:
my $server = "email-smtp.us-east-1.amazonaws.com"; my $port = 465; my $mailer = Email::Send->new( { mailer => 'SMTP::TLS', mailer_args => [ Host => $server, Port => $port, User => $username, Password => $password, Hello => 'testdomain.com', ] } ); use Email::Simple::Creator; my $email = Email::Simple->create( header => [ From => $from, To => $to, Subject => 'Test Email', ], body => 'This is a test', ); eval { $mailer->send($email) }; die "Error sending email: $@" if $@;
Because they are both hanging it really makes me think it is a port issue. But the fact that I can connect from the command line and that both packages are hanging (even though I am specifying the port) really has me at a loss. I know this is not a lot to go on, but any ideas, insight or other packages I should try would be greatly appreciated!

Thanks!


In reply to SMTP and TLS by Rodster001

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.