Page 1 of 1

Mail Form not Mailing

Posted: Sun Mar 12, 2006 12:44 am
by enigm4_
feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


Hi Guys,

I've been grappling with this mail form quite a bit in the last week or so.  I can't seem to get it to mail after error checking.  It was working when I used it without the error checking.

[url]http://www.reakt.com.au/inner.php?contact[/url]

I have no idea where to go anymore.  I've tried a thousand different ideas .If anyone know why it is broken, please let me know!

Here is the code (sorry it's so long!)

Code: Select all

echo  "<h1>Contact reAKT!</h1>
<p>Want to let us know of something?  Found a broken link?  Just want to give us some feedback on the magazine and website?  Email us from here and we'll be sure to respond as fast as we possibly can!</p>
<p>If you are looking to make a submission, please use the form located in the <a href=\"inner.php?submit\">submissions area</a>.  Submissions submitted through this form will not be correctly routed and may take a long time to be read and replied to.</p>
<div id=\"content\">";




	if(isset($_POST['submit'])) {
		echo '<div class="phpoutput"><p class="fail">';

		//Get the phone number if they entered one
		$phone=$_POST['phone'];
		//Get the comments they have entered
		$comments=$_POST['comments'];
		
		//Check for a name
		if(eregi("^[[].' -]{2,15}$", stripslashes(trim($_POST['name'])))) {
			$frmname=escape_data($_POST['name']);
		} else {
			$frmname=FALSE;
			echo'Please enter a name.<br />';
		}
		
		//Check for an email address
		if(eregi("^[[]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$", stripslashes(trim($_POST['email'])))) {
			$frmemail=escape_data($_POST['email']);
		} else {
			$frmemail=FALSE;
			echo 'Please enter a valid email address. (example: user@provider.com.au)<br />';
		}
		
		//if the details above are all entered, then send the email to online@reakt.com.au
		if($frmname && $frmemail) {
			
			//Create the Subject Line
			$subject="reAKT! Comments Form Submission";
		
			//Compose simple text message:
			$message="
				Name:                      $frmname \n
				Email:                     $frmemail \n
				Phone:                     $phone \n\n
				Comments:                  $comments
			";
		
			 //Mail the form to online@reakt.com.au
			mail("online@reakt.com.au", $subject, $message, $frmemail);
			
			//echo a response
			echo "Thankyou, your query will be responded to as soon as possible.";
			
		//If the above has any errors, output the end of the errors.
		} else {
			echo 'Please fill in all required fields and try again.';
		}
	echo '</p></div><br />';
	}

	echo"<form action=\"";$_SERVER['PHP_SELF'];echo "\" method=\"post\">
		<fieldset>
			<legend>Contact Form</legend>
			<div class=\"information\">
				<h4>Information</h4>
				<p>If you want to make a submission, please don't use this form.  Use the submission form located in the <a href=\"inner.php?submit\">submissions section</a>.</p>
			</div>
			<div class=\"forms\">
				<label for=\"name\">Your Name</label><input name=\"name\" id=\"name\" type=\"text\" value=\""; if(isset($_POST['name'])) echo $_POST['name']; echo"\" tabindex=\"1\" />
				<label for=\"email\">Your Email</label><input name=\"email\" id=\"email\" type=\"text\" value=\""; if(isset($_POST['email'])) echo $_POST['email']; echo"\" tabindex=\"2\" />
				<label for=\"phone\">Your Phone Number</label><input name=\"phone\" id=\"phone\" class=\"sminp\" type=\"text\" value=\""; if(isset($_POST['phone'])) echo $_POST['phone']; echo"\" tabindex=\"3\" />
				<label for=\"comments\">Comments</label><textarea cols=\"5\" rows=\"4\" name=\"comments\" id=\"comments\" tabindex=\"4\">"; if(isset($_POST['comments'])) echo $_POST['comments']; echo"</textarea>
				<br class=\"brclear\" />
				<label></label><input name=\"submit\" class=\"sminp\" type=\"submit\" value=\"Submit\" tabindex=\"5\" />
			</div>
		</fieldset>
		<br class=\"clearrt\" />
	</form>
</div>
<hr />";

feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Sun Mar 12, 2006 12:54 am
by feyd
if you print out $message (if it gets that far) does it all look correct?

Posted: Sun Mar 12, 2006 1:00 am
by enigm4_
[edit]

Apoligies, I tell a lie, I put the echo in the wrong spot >slaps head<

Outputs the $message content without a problem

Posted: Sun Mar 12, 2006 1:06 am
by feyd
try

Code: Select all

mail("online@reakt.com.au", $subject, $message, 'From: ' . $frmemail) or die('failed to send mail');

Posted: Sun Mar 12, 2006 1:18 am
by enigm4_
Cheers, tried that but it's still not sending me any email at all.

Still outputs the message though, so it seems to work up until the mail() command.

Posted: Sun Mar 12, 2006 1:39 am
by feyd
If you don't get "failed to send mail" then the mail was successfully processed. That doesn't mean the mail didn't get very far though. Check the main mail account associated with the server, you may get bounces or it may show up in the spam/junk bin of the receiving account.

Posted: Sun Mar 12, 2006 1:46 am
by enigm4_
I know it isn't the Junk account of my mail as I check that regularly as well for such things.

I'm not sure how to check the main mail account on the server as I do not administer it.

I'll take it up with the hosts, see what htey can see from their end.

Thanks for your help