Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

SendMail won't send mail

by belize (Deacon)
on May 24, 2001 at 01:43 UTC ( [id://82747]=perlquestion: print w/replies, xml ) Need Help??

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

I have a simple CGI that takes a form and sends an email with the contents of the form.

Everything appears to work fine and the success page shows (which should only show if the CGI correctly makes it through all the other sub routines).

Problem is that no email is being sent. I know I should be using CGI.pm, but the current CGI has always worked in the past, and is already in place with the forms and all.

Is there a way to test if SendMail is working? I have:

1. Looked for and not found any dead.letter file
2. Looked in the error logs (nothing)
3. Used the following code:

sub SendMail { if (-e $FORM{'template'}) { } else { &Error('Template File Not Found - Error at sendmail subscript') +; } open (FILE, $FORM{'template'}); @File = <FILE>; close (FILE); open (MAIL, "|$mailprog -t") || &Error('Unable to Open Sendmail'); . . . }

but no error shows up which makes me think that SendMail is opening.

I've checked the SMTP service on the host servers and they are running.

I'm running out of things to check. Any ideas?

Replies are listed 'Best First'.
Re: SendMail won't send mail
by merlyn (Sage) on May 24, 2001 at 01:54 UTC
    Not commenting on your sendmail problem, but I saw this glaring issue and had to perk up:
    if (-e $FORM{'template'}) { } else { &Error('Template File Not Found - Error at sendmail subscript') +; } open (FILE, $FORM{'template'});
    What's to stop someone from sending C</etc/passwd> as your template? Or even worse, playing games with NULs, which terminate C's scan on the -e test, but not Perl's scan on the open!

    Get that scary code out of your CGI at once.

    -- Randal L. Schwartz, Perl hacker

Re (tilly) 1: SendMail won't send mail
by tilly (Archbishop) on May 24, 2001 at 02:08 UTC
    Why would any error show up when you are doing an open without following the advice in perlsyn and putting in a check for errors? A check that should include what you are going and the context fo $!.

    That said, I would suggest Mail::Send for the problem...

Re: SendMail won't send mail
by rucker (Scribe) on May 24, 2001 at 04:28 UTC
    You don't show the close(MAIL), but I'm guessing that you're not checking errors there. If your "$mailprog -t" returns an error, it'll show up on the close.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-03-29 12:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found