0

I tried below code but it was not working correctly. please help me

<?php
$email = $_POST['email'];
$feedback = $_POST['feedback'];

$to = "balvant1@gmail.com";
$subject = "Mail from HRMSsystem for New Requirement";
$message .= "<b>Email : $email </b>"; 
$message .= "<b>feedback : $feedback </b>"; 
$header = "From:xyz@info.com \r\n";
$header = "Cc:balvant@gmail.com \r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html\r\n";
$retval = mail($to,$subject,$message,$hearder);
if( $retval == true )
{echo "Message sent successfully...";}
else{ echo "Message could not be sent..."; }

?>

Thanks in advance.

RiggsFolly
  • 83,545
  • 20
  • 96
  • 136

2 Answers2

0

Three things...

  1. Most hosting companies don't allow you to "bounce" mail off of their servers so unless you own the domain info.com AND you are hosting it on their server, chances are your mail is being blocked.

  2. As @Louis Loudog Trottier said, $retval = mail($to,$subject,$message,$hearder); should be $header not $hearder

  3. You don't necessarily have to have "xyz@info.com" set up. I often use noreply@my-domain-name.tld (which is a non-existent email address) to send mail, BUT you do have to comply with #1.

Also, see the comment by @Svengali as well

Kuya
  • 6,423
  • 4
  • 15
  • 31
  • @ParmarBalvant - Do you need more help? If this answer was helpful to you and answered your question, please don't forget to [accept that answer](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work). Also see [What does it mean when an answer is "accepted"?](http://meta.stackexchange.com/help/accepted-answer) and [Why is voting important?](http://meta.stackexchange.com/help/why-vote). – Kuya Sep 24 '15 at 06:43
0

Although not a direct answer to your question, using mail() to send your emails is seldom a good idea. Using an email class library is simpler and more straight forward in my opinion.

Please have a look at swiftmailer.org for example.

Henkealg
  • 1,246
  • 1
  • 14
  • 18