Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Send email without using SMTP server

by madtoperl (Hermit)
on Nov 13, 2008 at 10:46 UTC ( [id://723407] : perlquestion . print w/replies, xml ) Need Help??

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

Hello Monks,
I need to send an email with xls file as attachment using perl. when I ran this below code,I got the following error
Connection error from localhost on port 25 ()
While googled this issue, it seems the SMTP server port is blocked. Could you please let me know how can I solve this issue.
The code is given below,
use Mail::Sendmail; %mail = ( To => 'tom@xyz.com', From => 'jerry@xyz.com', Message => "This is a very short message" ); sendmail(%mail) or die $Mail::Sendmail::error; print "OK. Log says:\n", $Mail::Sendmail::log;

Replies are listed 'Best First'.
Re: Send email without using SMTP server
by fmerges (Chaplain) on Nov 13, 2008 at 12:18 UTC

    Hi,

    Your problems look more like you don't have installed any MTA on your system, do you?

    Read the docs of the module, you can provide the option of the SMTP server you gonna use like:

    my %mail = ( To => 'tom@xyz.com', From => 'jerry@xyz.com', Message => "This is a very short message", smtp => 'smtp.xyz.com', );

    Another module I could recommend is Mail::Mailer.

    Regards,

    fmerges at irc.freenode.net
Re: Send email without using SMTP server
by jettero (Monsignor) on Nov 13, 2008 at 11:34 UTC
    You'll probably end up using MIME::Lite with the Net::SMTP option (see change how messages are sent).

    -Paul

    A reply falls below the community's threshold of quality. You may see it by logging in.