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

Hi,

I've a hosting account with pair and I don't seem to have any luck using Mail::Sendmail via a web form.

use Mail::Sendmail; sub notify { my ($recipient, $message) = @_; my %mail = ( To => $recipient, From => 'me@hey.com', Message => $message ); sendmail(%mail) or die $Mail::Sendmail::error; }
I'm totally lost here. Apparently, Mail::Sendmail is installed on their server but it just won't work.

I've a similar piece of code which I use for local testing. That one works:

use Mail::Sendmail; unshift @{$Mail::Sendmail::mailcfg{'smtp'}} ,'smtp.someserver.com'; sub notify { my ($recipient, $message) = @_; %mail = ( To => $recipient, From => 'me@here.com', Message => $message ); sendmail(%mail) or die $Mail::Sendmail::error; }
Could someone help shed some light on what I'm missing?

Thanks in advance :)

Replies are listed 'Best First'.
Re: Mail::Sendmail help
by matija (Priest) on Feb 22, 2004 at 16:22 UTC
    Well, from Mail::Sendmail's documentation it's clear that if @{$Mail::Sendmail::mailcfg{'smtp'}} isn't set, then it tries to send through localhost.

    It would appear that you don't have a sendmail (or other MTA) on your port 25.

    You can test that by doing

    telnet localhost 25

    I'm betting you'll get connection refused.

    And that means you either have to pick another server that will allow you to send mail through it, or install a mailserver on your localhost.

Re: Mail::Sendmail help
by PodMaster (Abbot) on Feb 22, 2004 at 12:14 UTC
    So you get no error/diagnostic messages at all? Try unshift @{$Mail::Sendmail::mailcfg{'smtp'}} ,'localhost';, and if that doesn't work try the other options (sendmail etc) and if all of those fail , contact your administrator so he can check the mail logs

    update: whoops, there are no other options, I was thinking of Mail::Sender

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      Thanks, PodMaster.

      I tried with 'localhost' and 'sendmail', still no luck. What other options are there?