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
https://forums.phpfreaks.com/topic/239101-php-mail-send-error/
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
https://forums.phpfreaks.com/topic/239101-php-mail-send-error/#findComment-1228485
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
https://forums.phpfreaks.com/topic/239101-php-mail-send-error/#findComment-1228486
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
https://forums.phpfreaks.com/topic/239101-php-mail-send-error/#findComment-1228488
Share on other sites

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.