Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Net::SMTP in the 21st Century

by samwyse (Scribe)
on Nov 18, 2013 at 15:33 UTC ( [id://1063126]=perlquestion: print w/replies, xml ) Need Help??

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

Back in the day, I could telnet to my local SMTP server and easily forge emails, to the amazement of my friends and colleagues. This week, I'm trying to get a web service to send an email verification email, and nothing is working. Right now, I'm using my laptop, and I've tried while both on and off my company's network, connecting to the server specified in my Exchange settings, my company's public MX record, and my home ISP's MX record. For all three, Net::SMTP returns undef, with no messages despite having debug tuned on, Mail::Sendmail is the same, and I can't even connect using telnet to port 23. For what it's worth, my Exchange server settings include "Logon network security: Negotiate Authentication". And while I'll be asking my company's IT staff, I thought I'd leave some breadcrumbs here for future seekers.

Replies are listed 'Best First'.
Re: Net::SMTP in the 21st Century
by daxim (Curate) on Nov 18, 2013 at 16:01 UTC
    Don't bother starting to automate with Perl (Email::Sender is super sweet) until you can get a successful SMTP session manually. This decade's best practice: encryption, authentication, submission port. Try variations of this:
    $ echo '\000mysmtpusername\000mysmtppassword' | openssl base64
    XDAwMG15c210cHVzZXJuYW1lXDAwMG15c210cHBhc3N3b3JkCg==
    
    $ # ↑↑↑↑ copy this to clipboard
    
    $ openssl s_client -connect mailhost.faraway.example.net:587 -starttls smtp
    
    ehlo hostname.here.example.org
    auth login XDAwMG15c210cHVzZXJuYW1lXDAwMG15c210cHBhc3N3b3JkCg==
    
    and you know the rest:
    mail from: <samwyse@host.here.example.org>
    rcpt to: <fnord@example.com>
    data
    ⋮
    
Re: Net::SMTP in the 21st Century
by hippo (Bishop) on Nov 18, 2013 at 15:41 UTC

    You might have more luck using telnet to port 25, since that is the SMTP port (23 is the telnet server port and is likely to be closed or firewalled anyway). In fact, if you did that first, your client address may be blacklisted as a result, which could be why you are getting nothing back. Just a thought.

Re: Net::SMTP in the 21st Century
by kschwab (Vicar) on Nov 18, 2013 at 17:45 UTC

    I assume this is because your ISP is blocking outbound port 25...many of them do. They do this mostly to keep botnets from spamming people.

    One option would be to create a gmail account and use it to relay the email. Gmail's SSL-enabled SMTP servers listen on port 465, which may not be blocked. CPAN has Email::Send::Gmail, or you could configure a local sendmail/postfix/whatever instance to relay it. Also, if having the notification come from a gmail.com address isn't desirable, you can use your own domains if you have a Google Apps account.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1063126]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-04-24 20:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found