Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Unable to send email using MIME::Lite

by EnPerl (Initiate)
on Apr 27, 2010 at 02:07 UTC ( #837000=perlquestion: print w/ replies, xml ) Need Help??
EnPerl has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I wrote the following code:
use strict; use warnings; use lib '/Users/SaumyaSingh/lib'; use MIME::Lite; my $user = "username"; my $pass = "pass"; MIME::Lite->send("smtp","smtp.mail.yahoo.com", AuthUser=>$user, AuthPass=>$pass,Port => 465, Debug => 1); my $msg = MIME::Lite->new ( From => 'saumya_mmmec@yahoo.com', To => 'saumya.singh@ndsu.edu', Data => "This is a test\n", Subject => "Test", ); $msg->send()
it gives me following error:
MIME::Lite::SMTP>>> MIME::Lite::SMTP MIME::Lite::SMTP>>> Net::SMTP(2.31) MIME::Lite::SMTP>>> Net::Cmd(2.29) MIME::Lite::SMTP>>> Exporter(5.62) MIME::Lite::SMTP>>> IO::Socket::INET(1.31) MIME::Lite::SMTP>>> IO::Socket(1.30_01) MIME::Lite::SMTP>>> IO::Handle(1.27) MIME::Lite::SMTP: Unexpected EOF on command channel at /Users/SaumyaSi +ngh/lib/MIME/Lite.pm line 2622 Failed to connect to mail server: Bad file descriptor at yahoo line 21

Any help would be highly appreciated

Thanks, Saumya

Comment on Unable to send email using MIME::Lite
Select or Download Code
Re: Unable to send email using MIME::Lite
by abubacker (Pilgrim) on Apr 27, 2010 at 04:17 UTC

    I hope the code is fine ! , there is something wrong with the internet connection (this is a doubt only ) ,
    my suggestion would be check your net connection.

      My internet connection is working fine, that was the first thing I made sure...
Re: Unable to send email using MIME::Lite
by ikegami (Pope) on Apr 27, 2010 at 04:17 UTC
    "Unexpected EOF on command channel" sounds like the remote end closed the connection.
      Is there a way out? I mean none of the code snippets I used to make it work correctly did the job. Do give me some suggestions....

        I'm not knowledgeable in this area. I just gave a tip to get you going since it had been two hours since you had posted and noone had replied. I then presumed the error would be most easily solved by checking the mail server to see why it closed the connection, but I hadn't notice you were using yahoo as your server.

Re: Unable to send email using MIME::Lite
by hesco (Deacon) on Apr 27, 2010 at 05:56 UTC
    I would suggest you start by testing the code against a mail server you own and control (as root), so you can review its logs to see how it handles this request. With cloud servers available these days for pennies an hour, creating and isolating a testbed for this is trivial. If it works on your own mail server, then you can try to iron out how to get yahoo's mail server to talk with you.

    -- Hugh

    if( $lal && $lol ) { $life++; }
    if( $insurance->rationing() ) { $people->die(); }
Re: Unable to send email using MIME::Lite
by arc_of_descent (Hermit) on Apr 27, 2010 at 09:18 UTC

    Your code seems to be ok. I suggest you test connecting to the SMTP server using other tools. If you're on *nix, the mail command might help. Also try telnetting directly to the SMTP server and check.

Re: Unable to send email using MIME::Lite
by ikegami (Pope) on Apr 27, 2010 at 21:07 UTC

    You're using the SSL port without telling MIME::Lite to use SSL, and you don't appear to be using the the correct host name.

    From http://help.yahoo.com/l/us/yahoo/mail/original/mailplus/pop/pop-14.html,

    • SMTP server: plus.smtp.mail.yahoo.com
    • Use SSL
    • Port: 465
    • Use authentication
    • Account Name/Login Name: Your Yahoo! Mail ID (your email address without the "@yahoo.com", for example, “testing80”)
    • Email Address: Your Yahoo! Mail address (for example, testing80@yahoo.com)
    • Password: Your Yahoo! Mail password

    Update: I swear I saw an Ssl => 1 option when I looked at the docs, but there isn't. I must have been looking at the wrong window. Later posts seem to indicate that SSL is automatically detected.

      The below code does that
      #!/usr/bin/perl #===================================================================== +========== # # FILE: ExampleMailer.pl # # USAGE: ./ExampleMailer.pl # # DESCRIPTION: # # OPTIONS: --- # REQUIREMENTS: --- # BUGS: --- # NOTES: --- # AUTHOR: S.SABARINATHAN (Sabarinathan), <sabarinathan@bksyste +ms.co.in> # COMPANY: Bk Systems (P) Ltd,Chennai # VERSION: 1.0 # CREATED: 04/28/10 12:52:40 IST # REVISION: --- #===================================================================== +========== use strict; use warnings; use MIME::Lite; use Net::SMTP; my $from = 'perlmail@bksys.co.in'; my $to = 'sabarinathan@bksys.co.in'; my $host = '192.168.1.1'; my $subject = 'A test message by script '; my $body = "Pls ignore this msg as this is test from perl scripts "; my $msg = MIME::Lite->new ( From => $from, To => $to, Subject => $subject, Type =>'multipart/mixed' ) or die "Error creating multipart container: $!\n"; $msg->attach ( Type => 'TEXT', Data => $body ) or die "Error adding the text message part: $!\n"; MIME::Lite->send('smtp', $host, Timeout=>60); $msg->send;
      Best Regards, S.Sabarinathan,
        Below code does the login
        #!/usr/bin/perl #===================================================================== +========== # # FILE: ExampleMailer.pl # # USAGE: ./ExampleMailer.pl # # DESCRIPTION: # # OPTIONS: --- # REQUIREMENTS: --- # BUGS: --- # NOTES: --- # AUTHOR: S.SABARINATHAN (Sabarinathan), <sabarinathan@bksyste +ms.co.in> # COMPANY: Bk Systems (P) Ltd,Chennai # VERSION: 1.0 # CREATED: 04/28/10 12:52:40 IST # REVISION: --- #===================================================================== +========== use strict; use warnings; use MIME::Lite; use Net::SMTP; my $from = 'YAHOO ID'; my $to = 'sabarinathan@bksystems.co.in'; my $host ='plus.smtp.mail.yahoo.com'; my $subject = 'A test message by script '; my $body = "Pls ignore this msg as this is test from perl scripts "; my $pass="********"; my $msg = MIME::Lite->new ( From => $from, To => $to, Subject => $subject, Type =>'multipart/mixed' ) or die "Error creating multipart container: $!\n"; $msg->attach ( Type => 'TEXT', Data => $body ) or die "Error adding the text message part: $!\n"; #MIME::Lite->send('smtp', $host, Timeout=>60,Auth=>'Yes',Port => 465, +Debug => 1); MIME::Lite->send('smtp', $host, Timeout=>60,Auth=>'LOGIN',AuthUser=>$f +rom,AuthPass=>$pass,Port => 465, Debug => 1); $msg->send;
        But i am getting below error in atuthen, MIME::Lite::SMTP>>> MIME::Lite::SMTP MIME::Lite::SMTP>>> Net::SMTP(2.31) MIME::Lite::SMTP>>> Net::Cmd(2.29) MIME::Lite::SMTP>>> Exporter(5.62) MIME::Lite::SMTP>>> IO::Socket::INET(1.31) MIME::Lite::SMTP>>> IO::Socket(1.30_01) MIME::Lite::SMTP>>> IO::Handle(1.27) MIME::Lite::SMTP=GLOB(0x8d0a970)<<< 220 smtp105.prem.mail.sp1.yahoo.com ESMTP MIME::Lite::SMTP=GLOB(0x8d0a970)>>> EHLO localhost.localdomain MIME::Lite::SMTP=GLOB(0x8d0a970)<<< 250-smtp105.prem.mail.sp1.yahoo.com MIME::Lite::SMTP=GLOB(0x8d0a970)<<< 250-AUTH LOGIN PLAIN XYMCOOKIE MIME::Lite::SMTP=GLOB(0x8d0a970)<<< 250-PIPELINING MIME::Lite::SMTP=GLOB(0x8d0a970)<<< 250 8BITMIME SMTP auth() command failed: No such file or directory Need MIME::Base64 and Authen::SASL todo auth
        Best Regards, S.Sabarinathan,

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2014-12-22 10:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (116 votes), past polls