Jump to content

Mail doesn't send


fluidsharp

Recommended Posts

Hi all,

I cannot send mail from one paid hosting, but from another I can (it is some free hosting)

How to debug or find out why it doesn't send mails?

 

<?php
error_reporting(E_ALL);

if (isset($clientName) && isset($clientEmail) && isset($clientMessage))
  {
$to  = "[email protected]";//. ", "; 
//$to .= "[email protected]";

$subject = "test mail from site";
$message = $clientMessage;

$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";


$l = mail($to, $subject, $message, $headers);
if ($l){echo "true";}else echo "false";
echo $l."<h3>Mail was sent</H3>";
print_r(error_get_last());
 error_log("error ", 1,"[email protected]");

  }

?>

 

Thank you in advance!

Link to comment
https://forums.phpfreaks.com/topic/242448-mail-doesnt-send/
Share on other sites

error.log I didn't find.

But example from http://php.net/manual/en/function.mail.php  (Example #4 Sending HTML email) works.

I think if I change $message = $clientMessage; to $message = "Test"; it will work.

I will check.

 

PS $clientMessage gets data from POST <textarea>.

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/242448-mail-doesnt-send/#findComment-1245531
Share on other sites

Try adding From: to the headers.

true, i missed this originally, in order for the mail function to work, a from header must be specified, either in the header parameter or in the php.ini file.

Your first step will be to add that to the function

 

it helped thanks! but why it works on an another server?

Link to comment
https://forums.phpfreaks.com/topic/242448-mail-doesnt-send/#findComment-1248422
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.