PHP Mailer 404 Error

Hi guys, I recently follow this tutorial to add a mailer to my website http://www.phphelp.com/article/article.php?art=2.

I’ve added it to my websites home page (http://main.storm-dorm-cleaners.com/) but when I attempt to submit the information to activate the email, It 404’s. My host is AWARDSPACE.COM

Below is the code I’ve entered for the site

<?php
/* Configuration -----------------------------------------*/
/* Mail results to this address                           */
/* Set this to the email address you wish to receive mail */
/* from the form submissions at.                          */

       $TO = "[email protected]";

/* Specify system mail program                            */
/* Set this to the path to your mail program. Check with  */
/* your server administrator for the proper location.     */

       $MP = "/usr/sbin/sendmail -t";

/*-------------------------------------------------------*/
/* Decide if we should display a new form or send the    */
/* form data by email.                                   */
/* To make this decision, the script can check for the   */
/* existence of 1) the action variable defined by a      */
/* hidden field; 2) a required form field that you know  */
/* will always be set on submission; or you may set the  */
/* action variable to a particular value that can be     */
/* checked to determine the action to take. I chose      */
/* to simply check for the existence of the hidden       */
/* action variable (which is always set as long as we    */
/* give a value in the hidden field).                    */
/*-------------------------------------------------------*/
if ($frmAction)
{
/*-------------------------------------------------------*/
/* A thank you message (or other response) goes here. We */
/* switch to HTML mode to make it easy to include any    */
/* tags you wish without worrying about quoted           */
/* attributes.                                           */
/*-------------------------------------------------------*/
?>
<div align="center">
<table width="350" border="2">
<tr>
	<td bgcolor="#C0C0C0">
<p>Thank you for contacting us, we will email you or send you a text soon.</p>
	</td
</tr>
</table>
</div>
<?php
/*-------------------------------------------------------*/
/* The real work gets done here by opening a pipe to     */
/* sendmail, which sends the contents of the submitted   */
/* form by email to the address specified in the         */
/* configuation section (which can acutally be an        */
/* an included initialization file if you want to get    */
/* fancy). For each variable we expect the form to       */
/* to submit, we output as part of the email.            */
/*-------------------------------------------------------*/
$fd = popen($MP,"w");
fputs($fd, "To: $TO ");
fputs($fd, "From: $frmName <$frmEmail> ");
fputs($fd, "Subject: Message from your web site ");
fputs($fd, "X-Mailer: PHP3 ");
fputs($fd, "Name: $frmName ");
fputs($fd, "Phone: $frmPhone ");
fputs($fd, "Email: $frmEmail ");
fputs($fd, "Details: $frmFurther");
pclose($fd);

/*-------------------------------------------------------*/
/* Here the script must exit so we don't display the     */
/* form again once the thank you message has been        */
/* displayed and the mail sent.                          */
/*-------------------------------------------------------*/
exit;
} else {
// start else clause
?>
<div align="center">
<form action="mail.php" method="post">
<table>
<tr>
	<td colspan="2"><p>Please enter your information so we may get in contact with you</p></td>
</tr>
<tr>
	<td>Name:</td>
	<td><input type="text" name="frmName" size="24"></td>
</tr>
<tr>
	<td>Phone:</td>
	<td><input type="text" name="frmPhone" size="24"></td>
</tr>
<tr>
	<td>Email:</td>
	<td> <input type="text" name="frmEmail" size="24"></td>
</tr>
<tr>
	<td>Message:</td>
	<td><input type="text" name="frmFurther" size="24"></td>
</tr>
<tr>
	<td>
<!-- To determine whether the script should display the form or 
mail the data, you can check for existence of a required field 
or this special action variable. -->
<input type="hidden" name="frmAction" value="formmail">
<input type="submit" value="Submit">
	</td>
	<td></td>
</table>
</div>
</form>
<?php
} // end else clause
?>

I’m confused why it 404’s. Can anyone help me out?

404 is that the file or resource is not found. Which url are you submitting the information to? Do you have a file there?

after carefully rereading the tutorial I realized I missed a huge step. Setting up some sort of mail program such as “sendmail”. Can someone point me in the right direction. Currently I’m looking at http://www.quackit.com/php/tutorial/php_mail_configuration.cfm, and found my sendmail path is “/usr/local/bin/sendmail -oi -t”, I set the $MP variable = /usr/local/bin/sendmail -oi -t but it still 404’s.

Still confused what to do

You said that the code is on your homepage, which means index.php

The form submits to mail.php, unless you have a mail.php, that is why you are getting the 404 error.

so what should I submit the form to? I tried index.php and it also 404’s. :-[

Sponsor our Newsletter | Privacy Policy | Terms of Service