Main Menu
Sub Menu
- Article Ref
- 6812-QPFK-4670
- Date Created
- Fri, 9th Jan 2004
- Date Modified
- Thu, 5th Jun 2014
formmail.cgi or PHP script that sends email no longer works
Question
My formmail.cgi or PHP script that sends me email no longer works and I made no changes. The forms submits the data sucessfully but no mail ever arrives to the target email address. What happened?
Answer
The reason your email does not arrive is most likely a SPAM control issue.
When you send an email using a CGI or PHP script, Qmail (our sendmail stand-in) reads the enviroment to determine how to set the Return-Path variable. This is the email address that is reported to the recipient's email server as the sender and is not to be confused with the From: or Reply-To: headers in the actual email itself which exist for the benefit of the email client program.
The default Return-Path for CGIs is anonymous@mail.qwknetllc.com and for PHP is root@mail.qwknetllc.com. These addresses have stigmas (may be on some blacklists) attached to them due to previous abuses of CGI/PHP scripts on the QWK.net servers and also because the users anonymous and root are suspect absent of the stigmas previously mentioned. Mail servers attempting to control SPAM may silently reject email with Return-Path headers containing those addresses or even anyuser@mail.qwknetllc.com. as mail.qwknetllc.com has been sufficiently abused as a sending host. While we try our best to prevent abuse of our system it has happend and these are the consequenses.
You can avoid this stigma by setting the Return-Path environment to something different. In a Perl based CGI, add somewhere near the top of you script:
$ENV{'MAILUSER'} = 'myusername';
$ENV{'MAILHOST'} = 'mydomain.com';
In a PHP script calling the mail function, prior to the mail command, add:
putenv("MAILUSER=myusername");
putenv("MAILHOST=mydomain.com");
This will set the Return-Path to 'myusername@mydomain.com' and should allow your mail to pass through. If you are using the formmail.cgi AS SUPPLIED by the QWK.net (H-Sphere) Control Panel, you can file a support ticket at http://customers.qwk.net/ and we will add the code free of charge.
It is our intention in the future to force these variables, but for now you will need to set them in your scripts.
Article Comments
There are currently no comments.