-2

I have use mail function like this work well in windows but not in linux server.what's wrong with my code..anyone can give some ideas/better one solution for this.I am also have refer some SMTP option but that all throw error while run time.

  <?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
$email_recipient = "staff@inpws.com";
$email_subject="hi";
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: info@oktakes.com\r\n"; 
$headers .= "Reply-To: info@oktakes.com";

$email_result = mail($email_recipient, $email_subject, "hiuu", $headers);
if ($email_result){ echo "Email has been sent!"; }
else{ echo "Email has failed!"; }
?>
Intrepid Uliyar
  • 91
  • 1
  • 2
  • 11

3 Answers3

0

$email_header doesn't exist.

$email_result = mail($email_recipient, $email_subject, $email_contents, $headers);

And in the 3rd line of $headers variable should be \r\n instrad of \n.

$headers .= "From: info@oktakes.com\r\n"; 
pavel
  • 26,538
  • 10
  • 45
  • 61
0

are you try to enable error to see the error as

error_reporting(E_ALL);
ini_set('display_errors', '1');

and you have a syntax error at this line

$email_contents .= "<br><b>Sender: " . hi uu;

should be

$email_contents .= "<br><b>Sender: " . "hi uu";

try that and see what is the error and replace $email_header with $headers

$email_result = mail($email_recipient, $email_subject, $email_contents, $email_header);
Osama Jetawe
  • 2,697
  • 6
  • 24
  • 40
  • i have change and ran it, but no error and mail not delivered..actually my hosting server is linux.i have read related to that..i think it may be some think issue related to web hosting / server..bro.. else.. – Intrepid Uliyar May 11 '15 at 11:05
0
$email_result = mail($email_recipient, $email_subject, $email_contents, $headers);
Michele d'Amico
  • 22,111
  • 8
  • 69
  • 76