Jump to content

Emails not sending with form submission


kobryan

Recommended Posts

I have used this for a while until recently i added the second email address to the form. For some reason it is not sending the emails after the addition. I wanted to make sure this is not a problem with my coding before i went to my server company and checked with them. thanks for any help.

<?php
	$form = "<form action='contact.php' method='post'>
	<table>
	<tr>
		<td></td>
		<td><font color='red'>*</font> are required</td>
	</tr>
	<tr>
		<td>Full Name:</td>
		<td><input type='text' name='fullname' class='textbox' size='56px'><font color='red'>*</font></td>
	</tr>
	<tr>
		<td>Phone:</td>
		<td><input type='text' name='phone' class='textbox' size='56px'><font color='red'>*</font></td>
	</tr>
	<tr>
		<td>City:</td>
		<td><input type='text' name='city' class='textbox' size='56px'><font color='red'>*</font></td>
	</tr>
	<tr>
		<td>Email:</td>
		<td><input type='text' name='email' class='textbox' size='56px'><font color='red'>*</font></td>
	</tr>
	<tr>
		<td>Questions/Comments:</td>
		<td><textarea type='text' name='comment' class='textbox' rows='7' cols='43'></textarea><font color='red'>*</font></td>
	</tr>
	<tr>
		<td></td>
		<td><input type='submit' name='submitbtn' class='button' value='Submit'></td>
	</tr>
	</table>
	</form>";
	
	if ($_POST['submitbtn']){
		$fullname = $_POST['fullname'];
		$email = $_POST['email'];
		$comment = $_POST['comment'];
		$phone = $_POST['phone'];
		$city = $_POST['city'];
		
		
		if ($fullname && $phone && city && $email && $comment){
		
			if (strstr($email, "@") && strstr($email, ".") && (strlen($email) >= 6)){
			
				mysql_query("INSERT INTO contact VALUES ('', '$fullname', '$phone', '$city', '$email', '$comment', NOW())");
			
				$webmaster = "[email protected], [email protected]";
				$headers = "From: $fullname<$email>";
				$subject = "Contact Us Form from $fullname";
				$message = "$fullname\r\n$phone\r\n$city\r\n$email\r\n$comment";
				
				mail ($webmaster, $subject, $message, $headers);
				
				echo "Your message has been sent. $form";
				
			}
			else
				echo"Please enter a valid email address. $form";
		}
		else
			echo "You did not enter all required information. $form";
		
	}
	else
		echo "$form";
	
	?>
Link to comment
https://forums.phpfreaks.com/topic/283902-emails-not-sending-with-form-submission/
Share on other sites

what second email address in the form? i only see one.

$webmaster = "#1 [email protected], #2 [email protected]";

Im sorry i must of used incorrect terms. The submission email that is going to me and my partner when i added my partners email address in the $webmaster section seemed to stop sending them all together. My DB still gets every submission. 

are the domains, the @xxx.com, in both of the email addresses the same?

 

anyway, you are probably triggering some relaying restrictions on your mail server. what if any php errors do you get when you add the following two lines of php code into your program -

ini_set("display_errors", "1");
error_reporting(-1);

 

are the domains, the @xxx.com, in both of the email addresses the same?

 

anyway, you are probably triggering some relaying restrictions on your mail server. what if any php errors do you get when you add the following two lines of php code into your program -

ini_set("display_errors", "1");
error_reporting(-1);

They are the same domain name in both email addresses.

 

I added the code but no errors appeared and the code seemed to start working again does that mean it was server side or is what you had me add what fixed it? I'm getting no PHP errors in my error log or on the page with this code since it seems like this is supposed to show the errors on the screen. 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.