in reply to SMTP authentication misery

Here is some working code that uses Net::SMTP::SSL.

I would have had this this morning, but it took me a long time to figure out that the LocalPort parameter is necessary, or else IO::Socket::INET fails in _sock_info().

#!/usr/bin/perl -w use strict; use warnings; use Net::SMTP::SSL; my $smtp = Net::SMTP::SSL->new( 'smtp.att.yahoo.com', Hello => 'mymachine.org', Port => 465, LocalPort => 0, # Necessary Debug => 1); die("smtp undefined: $@") if !defined $smtp; my $acct_id = "your_full_userid_here"; # name@domain my $acct_pw = "your_password_here"; my $dest_addr = "destination_email_address"; # name@domain # Note two argument standard form. my $auth_return = $smtp->auth($acct_id, $acct_pw); # The mail() address must be your account's user id or else you'll get # the dreaded "553 From address not verified" error. # You cannot simply use $ENV{USER}. my $mail_return = $smtp->mail($acct_id); my $to_return = $smtp->to($dest_addr); $smtp->data(); $smtp->datasend("To: $dest_addr\n"); $smtp->datasend("From: $acct_id\n"); # Could be any address $smtp->datasend("Subject: Sending with Net::SMTP::SSL\n"); $smtp->datasend("\n"); # Between headers and body $smtp->datasend("This is the body, line1\n"); $smtp->datasend("This is the body, line2\n"); $smtp->dataend(); $smtp->quit; print "\nauth_return = $auth_return\n"; print "mail_return = $mail_return\n"; print "to_return = $to_return\n";

Replies are listed 'Best First'.
Re^2: SMTP authentication misery
by cypress (Beadle) on Nov 23, 2009 at 17:56 UTC

    Thanks, gmargo, for all of your work.

    Unfortunately, even using your code, I'm still getting a "530 Access denied" error right after my password is sent to the ISP via $smtp->auth().

    (One small difference -- somewhat embarrassing but, hey, Macs are a new world for me -- I don't know 'mymachine' here or how to determine this name. I just commented out your line, allowing 'localhost.localdomain' as default. I doubt this has anything to do with my auth error.)

      That mymachine.org doesn't mean anything, I forgot to change it back to 826michigan.org. In any case, it's not relevant - I just tried it successfully with the default localhost.localdomain.

      Since the auth step is failing it must be an id/password issue (unless you're still using the 3-argument auth!). I'm not sure what else to do. Random thoughts: Are you an ATT DSL customer like me? Are you using the DSL account id or an additional email id? Did you escape the '@' in the email address? Does the same id/password work on the web email interface http://att.yahoo.com/mail?

        Ah ha! Good questions!

        1 Yes, it is DSL service here.

        2 I'm not sure what a DSL account id would be (an email address provided by at&t for our DSL account?), but info@826michigan.org is probably what you mean by 'additional email id.'

        3 Yes, I did escape the @.

        4 No, http://att.yahoo.com/mail does not let me login! Username and password are valid, however, as login is possible via http://webmail.826michigan.org.

        A bit of background. 826michigan is a small, educational non-profit. I'm merely a part-time volunteer without a whole lot of technical expertise, though perhaps more than the other liberal arts folks here. My supervisor, who confessed she had no idea what a router was, also had no idea who our ISP was. I had to determine this from a telephone bill, then call at&t for an smtp address. smtp.att.yahoo.com was the address given me by the sbcglobal tech for our DSL account.

        Our organization's website and the email addresses associated with it aren't likely hosted by at&t/sbcglobal/yahoo, however. It was setup and is maintained by some guy up in Canada -- just another do-gooder like me. Could therein be the source of my misery? Do I need some sort of 'account id' directly provided by at&t/sbcglobal/yahoo to be recognized and authenticated by same?

        Thanks, again and again. -cypress

        Be glad, sitting in your gray-walled cubicle, that at least you weren't an English major.

        Ah ha! Good questions!

        1 Yes, it is DSL service here.

        2 I'm not sure what a DSL account id would be (an email address provided by at&t for our DSL account?), but info@826michigan.org is probably what you mean by 'additional email id.'

        3 Yes, I did escape the @.

        4 No, http://att.yahoo.com/mail does not let me login! Username and password are valid, however, as login is possible via http://webmail.826michigan.org.

        A bit of background. 826michigan is a small, educational non-profit. I'm merely a part-time volunteer without a whole lot of technical expertise, though perhaps more than the other liberal arts folks here. My supervisor, who confessed she had no idea what a router was, also had no idea who our ISP was. I had to determine this from a telephone bill, then call at&t for an smtp address. smtp.att.yahoo.com was the address given me by the sbcglobal tech for our DSL account.

        Our organization's website and the email addresses associated with it aren't likely hosted by at&t/sbcglobal/yahoo, however. It was setup and is maintained by some guy up in Canada -- just another do-gooder like me. Could therein be the source of my misery? Do I need some sort of 'account id' directly provided by at&t/sbcglobal/yahoo to be recognized and authenticated by same?

        Thanks, again and again. -cypress

        Be glad, sitting in your gray-walled cubicle, that at least you weren't an English major.