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

Hi Monks, I'm trying to send a simple email (hello world text) from my gmail account. Searching cpan I found the module Email::Send::Gmail. After installing it successfully, I'm running the synopsis-like snippet to test it:
#!/usr/bin/perl use strict; use warnings; use Email::Send; use Email::Send::Gmail; use Email::Simple::Creator; my $email = Email::Simple->create( header => [ From => 'magic_monitoring@gmail.com', To => 'acme@astray.com', Subject => 'Server down', ], body => 'The server is down. Start panicing.', ); my $sender = Email::Send->new( { mailer => 'Gmail', mailer_args => [ username => 'magic_monitoring@gmail.com', password => 'XXX', ] } ); eval { $sender->send($email) }; die "Error sending email: $@" if $@;
Replacing the gmail accounts and the password with valid ones. The context of execution is: Ubuntu 8.04 (uname -a: Linux 2.6.24-21-generic #1 SMP Mon Aug 25 17:32:09 UTC 2008 i686 GNU/Linux) perl -v -> v5.8.8 perl -MEmail::Send::Gmail -e 'print $Email::Send::Gmail::VERSION' -> 0.33 telnet smtp.gmail.com 995 -> Trying 216.239.59.109... Connected to gmail-smtp-msa.l.google.com. Escape character is '^]' Output of running the script: Error sending email: Email::Send::Gmail: error authenticating username myaccount@gmail.com at /usr/local/share/perl/5.8.8/Email/Send.pm line 243 Anyone have any idea what's going on here? (the script worked on a leopard plataform) Thanks in advance!

Replies are listed 'Best First'.
Re: Sending a simple email using Email::Send::Gmail
by Krambambuli (Curate) on Oct 25, 2008 at 17:08 UTC
    Instead of
    username => 'magic_monitoring@gmail.com',
    try to use just
    username => 'magic_monitoring',
    I was able to reproduce the problem on my WS, and the problem went away when I changed my credentials not to contain @gmail.com.


    Krambambuli
    ---
      Thanks for answering! I've changed username => 'diffredential', but the same error appears after running it:
      diffred@fredlab:~/pathscripts$ ./sendemail.pl Net::SMTP::SSL>>> Net::SMTP::SSL(1.01) Net::SMTP::SSL>>> IO::Socket::SSL(1.17) Net::SMTP::SSL>>> IO::Socket::INET(1.29) Net::SMTP::SSL>>> IO::Socket(1.29) Net::SMTP::SSL>>> IO::Handle(1.25) Net::SMTP::SSL>>> Exporter(5.58) Net::SMTP::SSL>>> Net::Cmd(2.29) Net::SMTP::SSL=GLOB(0x8580dd0)<<< 220 mx.google.com ESMTP g11sm3962449 +gve.8 Net::SMTP::SSL=GLOB(0x8580dd0)>>> EHLO localhost.localdomain Net::SMTP::SSL=GLOB(0x8580dd0)<<< 250-mx.google.com at your service, [ +80.32.103.182] Net::SMTP::SSL=GLOB(0x8580dd0)<<< 250-SIZE 35651584 Net::SMTP::SSL=GLOB(0x8580dd0)<<< 250-8BITMIME Net::SMTP::SSL=GLOB(0x8580dd0)<<< 250-AUTH LOGIN PLAIN Net::SMTP::SSL=GLOB(0x8580dd0)<<< 250 ENHANCEDSTATUSCODES Error sending email: Email::Send::Gmail: error authenticating username + diffredential at /usr/local/share/perl/5.8.8/Email/Send.pm line 243 at ./sendemail.pl line 29 diffred@fredlab:~/pathscripts$
      Any other ideas? :(
        When installing IO::Socket::SSL, I had to also install Net::SSLeay and while I did that I was warned that

        *** Found OpenSSL-0.9.8b installed in /usr                                              
        *** Be sure to use the same compiler and options to compile your OpenSSL, perl,         
            and Net::SSLeay. Mixing and matching compilers is not supported.                    
        

        Is it possible that the modules you have installed don't play well together ?


        Krambambuli
        ---
Re: Sending a simple email using Email::Send::Gmail
by Anonymous Monk on Oct 25, 2008 at 00:38 UTC
    Turn on debugging
      diffred@fredlab:~/pathscripts$ ./sendemail.pl Net::SMTP::SSL>>> Net::SMTP::SSL(1.01) Net::SMTP::SSL>>> IO::Socket::SSL(1.17) Net::SMTP::SSL>>> IO::Socket::INET(1.29) Net::SMTP::SSL>>> IO::Socket(1.29) Net::SMTP::SSL>>> IO::Handle(1.25) Net::SMTP::SSL>>> Exporter(5.58) Net::SMTP::SSL>>> Net::Cmd(2.29) Net::SMTP::SSL=GLOB(0x8580d7c)<<< 220 mx.google.com ESMTP g11sm3140596 +gve.8 Net::SMTP::SSL=GLOB(0x8580d7c)>>> EHLO localhost.localdomain Net::SMTP::SSL=GLOB(0x8580d7c)<<< 250-mx.google.com at your service, [ +80.32.103.182] Net::SMTP::SSL=GLOB(0x8580d7c)<<< 250-SIZE 35651584 Net::SMTP::SSL=GLOB(0x8580d7c)<<< 250-8BITMIME Net::SMTP::SSL=GLOB(0x8580d7c)<<< 250-AUTH LOGIN PLAIN Net::SMTP::SSL=GLOB(0x8580d7c)<<< 250 ENHANCEDSTATUSCODES Error sending email: Email::Send::Gmail: error authenticating username + diffredential@gmail.com at /usr/local/share/perl/5.8.8/Email/Send.pm + line 243 at ./sendemail.pl line 29 diffred@fredlab:~/pathscripts$
      Also, I've donwloaded this perl script to send emails: http://caspian.dotconf.net/menu/Software/SendEmail/ and it sends the email properly!! So I cannot understand why this script works on sending an email in my PC and mine posted here don't (which works on Mac OSX!). Quite a flying experience.
        it sends the email properly!!
        No it doesn't, as It doesn't use gmail service (and your gmail account).

        So I cannot understand why this script works on sending an email in my PC and mine posted here don't (which works on Mac OSX!). Quite a flying experience.

        See Re^5: Sending a simple email using Email::Send::Gmail, you might figure it out.

Re: Sending a simple email using Email::Send::Gmail
by zentara (Cardinal) on Oct 25, 2008 at 20:30 UTC
    A guess is that you have your auth type wrong. You seem to be using PLAIN LOGIN. Maybe try:
    $sender->auth("username","password"); # see perldoc $sender->send($email)

    I'm not really a human, but I play one on earth Remember How Lucky You Are
      Thanks for answering, but I didn't realize what you suggest me to do, how should I edit my code?
        Surprisingly enough, I've tried this script into another platform but +same system. In a macbook santa rosa with an Ubuntu 8.04 partition , +it works both in Leopard (Mac OS X) and Ubuntu 8.04 partitions. So I guess the problem I have is specific of the PC I'm running it. An +yone any idea of commands that can help me checking the differences b +etween the Ubuntu partition on the macbook and the Ubuntu partition o +n the PC (which are supposed to have same packages)?