Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

MIME::Lite error => SMTP auth() command not supported on smtp.gmail.com

by ted.byers (Scribe)
on Sep 13, 2011 at 21:12 UTC ( #925773=perlquestion: print w/ replies, xml ) Need Help??
ted.byers has asked for the wisdom of the Perl Monks concerning the following question:

Hi All

I have a particularly obscure and puzzling problem. The following code works perfectly on my workstation (64 bit Windows 7, 64 bit Activestate perl 5.12). I am trying to set the script up on a Server running Windows Server 2003 (but the same version of Perl - in fact, I copied the whole C:\Perl64 directory tree from the above workstation to the server, which happend very quickly over a 1GB LAN, and set up the environment variables appropriately)

Alas, the problem is that while the script works perfectly on the workstation, it dies with the above error on the server.

I did do a search of this forum, and found information about 'use Authen::SASL qw(Perl);'. Authen::SASL is in fact installed, and adding the use statement 'use Authen::SASL qw(Perl);' at the beginning of the script changes nothing!

Here is the code:

use strict; use MIME::Lite; my $subject="A first MIME::Lite test on gmail"; my $message="A Daily PDF report is attached.Just to see if this works" +; my $to = "r.ted.byers\@gmail.com"; my $file = "mysamplefile.pdf"; my $from = "\"Me\" <me\@here.com>"; print "Sending test email.\n"; make_and_send_email($from,$to,$subject,$message,$file); print "Test email sent.\n"; sub make_and_send_email{ my ($from, $to,$subject,$message, $path) =@_; my $un='myun'; my $pw='mypwd'; my $msg = MIME::Lite->new( From => $from, 'Reply-to' => $from, To => $to, Subject => $subject, Type =>'multipart/related' ) or die "Cannot create a new email instance!"; $msg->attach(Type => 'TEXT', Data => $message, ) or die "Error adding TXT: $!\n"; $msg->attach(Type => 'aplication/pdf', Path => $path, Disposition => 'attachment' ) or die "Error adding PDF: $!\n"; MIME::Lite->send('smtp','smtp.gmail.com',AuthUser=>$un, AuthPass=>$p +w, Timeout => 60); $msg->send(); return 0; }

Here is the output on the workstation:

C:/Perl64/bin\perl.exe -w c:/Work/gmail.test.pl 
Sending test email.
Test email sent.

Compilation finished at Tue Sep 13 11:33:59

and here is the output on the server:

C:/Perl64/bin\perl.exe -w c:/Work/gmail.test.pl 
Sending test email.
SMTP auth() command not supported on smtp.gmail.com

Compilation exited abnormally with code 255 at Tue Sep 13 16:47:12

Since I copied everything in C:\Perl64 on the workstation to the same location on the server (and set PERL_HOME to C:\Perl64 as an environment variable), what could possibly be different between the two machines that would account for the different outcomes? Of course, I used the same credentials on both machines.

This is the first time I have shifted code from one machine to another only to find it breaking (and in fact I do this alot).

Any guidance on how to fix this would be appreciated.

Thanks

Ted

Comment on MIME::Lite error => SMTP auth() command not supported on smtp.gmail.com
Download Code
Re: MIME::Lite error => SMTP auth() command not supported on smtp.gmail.com
by keszler (Priest) on Sep 14, 2011 at 00:17 UTC

    Is MIME::Base64 installed?

    MIME::Lite->send('smtp'... uses Net::SMTP, which in its auth method does:

    eval { require MIME::Base64; require Authen::SASL; } or $self->set_status(500, ["Need MIME::Base64 and Authen::SASL tod +o auth"]), return 0;

    MIME::Lite code includes:

    if ($smtp->supports('AUTH',500,["Command unknown: 'AUTH'"])) { $smtp->auth( $args{AuthUser}, $args{AuthPass} ) or die "SMTP auth() command failed: $!\n" . $smtp->message . "\n"; } else { die "SMTP auth() command not supported on $hostname\n"; }

    It appears possible that the lack of MIME::Base64 could result in the error you're seeing.

      Thanks.

      Yes, MIME::Base64 is installed.

      What else might be awry?

        In all of the MIME::Lite code that particular error message only appears once, as shown. Net::SMTP->supports('AUTH'... fails, that error is generated. So, why does it fail from the server when it succeeds on your workstation. Same Perl, same modules; time to look elsewhere. Is the server blocked from connecting to gmail.com? Since this is email, is something on your network redirecting email ports to local email servers?

        On the server, at a DOS prompt, try:

        > telnet smtp.gmail.com 25

        If you get a connection, you'll see something like 220 smtp.gmail.com.... If you can't connect, or get a local email server - there's your problem.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2014-09-24 03:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (244 votes), past polls