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

anyone who has tried the perl module from CPAN "Mail::Sendmail v. 0.78 - Simple platform independent mailer " ? i fail to run the provided test.pl program ... mail can't be sent successfully ... error reported.~! um ... anyone can teach me how to send mail through my smtp server by using any perl module? the OS i'm using is win2000/NT and Perl version: v5.6.0 built for MSWin32-x86-multi-thread however, i have error like this ...

Replies are listed 'Best First'.
Re: send mail using SMTP
by zigster (Hermit) on Mar 02, 2001 at 16:47 UTC
    As has been said use Net::SMTP a little sample follows, change the ip address in the new clause to be your smtp server. If you are still having problems try telneting to the port you think your smtp server is hanging on (should be port 25) so telnet host 25 will connect you should see something like:
    <HOST> ESMTP Sendmail 8.8.3 ready at <date>
    
    Close the connection here, if you dont get this echo (or something similar then you are pointing your client at a duff smtp server.
    use Net::SMTP; my $from='from@email.domain'; my $to='to@email.domain'; my $smtp= Net::SMTP->new('127.0.0.1', Timeout => 180); $smtp->mail($from); $smtp->to($to); $smtp->data(); $smtp->datasend("YOUR MESSAGE"); $smtp->dataend(); $smtp->quit();
    UPDATE:

    I forgot to mention this kind of question has been covered lots have a look at Super search and search for smtp you will get nuff help and examples. If after looking through those you are still at a loss then come back and I am sure someone will help ya out... Enjoy.
    --

    Zigster

Re: send mail using SMTP
by davorg (Chancellor) on Mar 02, 2001 at 16:26 UTC

    You could try the Net::SMTP module. It's part of the libnet bundle.

    --
    <http://www.dave.org.uk>

    "Perl makes the fun jobs fun
    and the boring jobs bearable" - me

Re: send mail using SMTP
by oakley (Scribe) on Mar 02, 2001 at 16:55 UTC
    One that I have used in the past, which I found to be *quite* easy to use was Mail::Sendmail - they even say that its platform independent =)

    Another good module that I have used recently is Mail::Mailer and its actually a part of the MailTools package.

    -oakley
    Embracing insanity - one twitch at a time >:)
Re: send mail using SMTP
by arhuman (Vicar) on Mar 02, 2001 at 16:44 UTC

    Fast and dirty way (Read No module), If you know the path to your SMTP compliant MTA.(here sendmail on a unix box)

    open(MAIL,"|/usr/lib/sendmail -oi -t") or die "Can't open Sendmail : $ +!\n"; print MAIL << "EOT"; From: fromuser\@fromsite.com To: destuser\@destsite.com Subject: Put your subject here Return-Path: fromuser\@fromsite.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Put Your message here, $variable can be used.. EOT close MAIL;
      You simply cant do this on a vanilla M$ system there is no compliant MTA. Ah CHU did say he was using M$, you could perform negot direct with the smtp server via a socket if you really wanted to avoid a module but why? Net::SMTP is soo easy.
      --

      Zigster
Re: send mail using SMTP
by sierrathedog04 (Hermit) on Mar 02, 2001 at 21:10 UTC
    I have used Perl and a free standalone NT program named blat.exe to send mail from a windows client using a remote SMTP server. I recommend it.

    Understand that no matter what type of mail client you use, your SMTP server will need to have its mail relay feature turned on. Most mail servers turn this feature off for security reasons.

    In my experience if mail relay is turned off then the SMTP server will give nondescript error messages that don't really identify the problem. If you have not done so you may wish to verify that your SMTP server has its mail relay feature enabled.