in reply to Re: Sendmail problems
in thread Sendmail problems

You might do better to use Net::SMTP, which avoids the whole issue of forking to a (possibly insecure) sendmail.

I don't know how many changes there would be, being a Perl novice. Also, I use the "NMS" FormMail.pl, which runs SENDMAIL just fine, but they may have used their own modules. Sendmail is used twice in the Perl script, and it all worked perfectly on a Unix box, but there have been many changes since moving the website (Linux box). Looking at the code, all the sendmail does it is heap of PRINT comands. Would SMTP be the same, so all I would have to change is the "open" function ?? I guess I'd better find out if the SMTP module runs on the website firts though. :)

If you are married to the open, what is the error message?

That's the trouble, even with the shebang line as

#!/usr/bin/perl -wT

there is no error message, the script just stops. I have a PRINT just before the 'open' and a PRINT right after, and it just sits there. Here is diehtml

sub diehtml { print start_html('Error processing order'), @_, end_html(), "\n"; exit 1; }

Thanks,

Peter

Replies are listed 'Best First'.
Re: Re: Re: Sendmail problems
by idsfa (Vicar) on Oct 03, 2003 at 05:20 UTC

    I think that there is no error message because your $! is being reset by the unlink. Using Net::SMTP, you would replace various of the prints with methods from Net::SMTP:

    (where ... == the rest of the line) open (SENDMAIL ...) ==> $smtp=new Net::SMTP("localhost"); print SENDMAIL "HELO ..." ==> (implicit) print SENDMAIL "MAIL ..." ==> $smtp->mail(...); print SENDMAIL "RCPT ..." ==> $smtp->to(...); print SENDMAIL "DATA" ==> $smtp->data(); print SENDMAIL "..." ==> $smtp->datasend(stuff); print SENDMAIL "." ==> $smtp->dataend(); print SENDMAIL "QUIT" ==> $smtp->quit();

    Note that your could replace the data/datasend/dataend chunk with a single data(@msg) call, if you build the text of the message into @msg.


    Remember, when you stare long into the abyss, you could have been home eating ice cream.
      I think that there is no error message because your $! is being reset by the unlink.

      Is there a method to reset my $! ?

      Using Net::SMTP

      Using a small test script, this appeared to work (after I got the SMTP server name right. :)

      Peter

Re: Re: Re: Sendmail problems
by Jenda (Abbot) on Oct 03, 2003 at 15:06 UTC

    You might try Mail::Sender then. It can give you a tied "filehandle" that you can print the message into.

    use Mail::Sender; ... my $sender = Mail::Sender->new(); $sender->Open({to => ..., from => ..., subject => ..., ...}); local *SENDMAIL = $sender->GetHandle(); print SENDMAIL "Hello there\nThis is the message!"; close SENDMAIL;

    Jenda
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
       -- Rick Osborne

    Edit by castaway: Closed small tag in signature