Jump to content

PHP Mail Send Error


Jacbey

Recommended Posts

Hi Guys, I'm having an annoying problem with sending this email. It keeps sending me the error but I fail to see the actual error in the code. Please help?

 

 $mailquery = "SELECT username, first_name, last_name, password, email, dob, mob, yob, year, gender FROM spotty WHERE user_id = '" . $id_receiver . "'";

$mailresult = mysql_query($mailquery) or die('Error Getting user_id');

$mailrow = mysql_fetch_array($mailresult);





//start message email send
	$email = $mailquery['email'];
	echo $email;
	$to = $email;
	//$from = "iWatch" ;
	$subject = $subject . " - iWatch";
	$from = "iWatch";
	$msgsub = $subject;

	$headers = "From: " . $from . "\r\n";
	$headers .= "MIME-Version: 1.0\r\n";
	$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

	$message = "
	<html> 
	  <body bgcolor='#DCEEFC'> 
	    <center> 
	        <b>Hi " . $to . ",</b> <br /> 
	        <font color='red'>" . $sender . " sent you a message.<br /></font> <br /> 


			<table>
			<tr>
			<td>From: </td>
			<td>" . $sender ."</a></font></td>
			</tr>
			<tr>
			<td>Subject: </td>
			<td>" . $msgsub . "</td>
			</tr>
			<tr>
			<td>Message: </td>
			<td>" . $body . "</td>
			</tr>
			</table>


	    </center> 
	      <br /><br />
		Regards; maker and founder of iWatch; Jacob Porter.
	  </body> 
	</html> 
	";
	$body = $message;
	if(mail($to, $subject, $body, $headers)) 
			{
			echo "Email sent to " . $friendusername .  "!";
	 		}
	else 

		{
	  echo("<p>Message delivery failed...</p>");
		}

	if($quer){
	echo "<meta http-equiv='refresh' content='4;url=http://www.klueless.net/daisysite/profile.php?id=" . $id_receiver . "&sent=1'>";}
else
{echo "<meta http-equiv='refresh' content='4;url=http://www.klueless.net/daisysite/profile.php?id=" . $id_receiver . "&sent=2'>";}

		}

}

 

Thanks in advance, Jacob :)

Link to comment
Share on other sites

Do you have error_reporting = -1 and display_errors = On in your php.ini file? You should always have those set to show you errors while developing (but not on live server). In this case, add these lines to the beginning of the script and post any additional errors that are returned.

 

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

Link to comment
Share on other sites

Do you have error_reporting = -1 and display_errors = On in your php.ini file? You should always have those set to show you errors while developing (but not on live server). In this case, add these lines to the beginning of the script and post any additional errors that are returned.

 

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

 

yeah I do. but it hasn't shown any errors.

 

Link to comment
Share on other sites

Should have maybe asked this first, but you do have a mail server set up on the web server you're using, right? Have you successfully sent mail from it previously?

 

Temporarily change the error message to echo the parameters that were sent to mail(). That output might provide enough information to figure out what's up with it.

 

if(mail($to, $subject, $body, $headers)) 
			{
			echo "Email sent to " . $friendusername .  "!";
	 		}
	else 

		{
	  echo("<p>Message delivery failed...</p><br>Mail parameters:<br><pre>To: $to<br>Subject: $subject<br>Body: $body<br>Headers: $headers</pre>");
		}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.