Forum Moderators: phranque

Message Too Old, No Replies

strange problem

         

TerryG

10:25 am on Aug 25, 2006 (gmt 0)

10+ Year Member



i have a customer who has been using Matts formmail and its has been working fine for well over 4 months.

all of a sudden it stops sending mail to them, they say they have done no changes to any program, i cant find any thing wrong.

it use to read /usr/sbin/sendmail but looking now at there hosts setup they are saying /usr/lib/sendmail, one would say changing it to reflect the change should allow it to start working but nope.

i am at a loss

rocknbil

6:00 pm on Aug 25, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



First I would look through the error logs for anything related to this script. This will tell you if it's not being able to connect with sendmail or mail. It's possible the program may run but just not connect with mail due to some change on the server.

Second, temporarily change the recipient to yourself to make sure it's not something on their mail server.

How are you at coding?

It's been a long time since I worked with Matt's scripts, but one thing I remember is that he frequently used this,

(do something) or die("can't do something $!");

In this case,

open (MAIL,"¦ $mailprog -t") or die("Cannot start $mailprog $!");

In a command line, this would print the error to the screen. When called from the browser, die doesn't actually do anything useful. I've found it's better to create an error trap that actually prints something to the browser. The module Carp allows you to call (paraphrase) fatals_to_browser, but a simpler method is your own error routine:


open (MAIL,"¦ $mailprog -t") ¦¦ &error("Cannot start $mailprog $!");
.... do mail stuff
close(MAIL);
sub error {
my ($error);
$error = shift(@_);
print "Content-type: text/html\n\n";
print "An error has occurred: $error.";
exit 0;
}

The perl variable $! holds system errors, such as "no such file or directory." A simple routine like this will print all the errors back to your browser - but you have to be careful where you use it so critical system info is not fed to unscrupulous eyes.

TerryG

11:33 am on Aug 26, 2006 (gmt 0)

10+ Year Member



thanks Bill.
ah one question tho, could ya put this little tid-bit together for me and let me know where to install it in that big file so i can get it working or at least figgured out.
p.s. for some reason the provider is not showing "error logs",?hummm?
cant find them any where..

encyclo

4:48 pm on Aug 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You should replace Matt's formmail with a more secure and better-written equivalent - even Matt himself says it is not safe to use his script anymore.

One recommended replacement is NMS-Formmail, which is a functional equivalent (ie. you don't have to make any changes to field names etc.):

[nms-cgi.sourceforge.net...]

You should rename it to something other than "formmail" as there are spiders specifically seaching for this script name to use it as a spam gateway. Many hosts disactivate (change permissions) of all scripts called "formmail" for this very reason.

Make sure the script has the appropriate permissions to be able to run (chmod 701 or 755 should do it).