0

I have the following script in php and I got the success message when I click submit, but not getting the email. I do not where I am doing wrong. Can somebody point out to the right direction please?

Thanks

  //$address = "HERE your email address";
    $address = "to_address@gmail.com";


// Below the subject of the email
$e_subject = 'You\'ve been contacted by ' . $name_contact . '.';

// You can change this if you feel that you need to.
$e_body = "You have been contacted by $name_contact $lastname_contact with additional message is as follows." . PHP_EOL . PHP_EOL;
$e_content = "\"$message_contact\"" . PHP_EOL . PHP_EOL;
$e_reply = "You can contact $last_name_contact via email, $email_contact.";

$msg = wordwrap( $e_body . $e_content . $e_reply, 70 );

$headers = "From: $email_contact" . PHP_EOL;
$headers .= "Reply-To: $email_contact" . PHP_EOL;
$headers .= "MIME-Version: 1.0" . PHP_EOL;
$headers .= "Content-type: text/plain; charset=utf-8" . PHP_EOL;
$headers .= "Content-Transfer-Encoding: quoted-printable" . PHP_EOL;

$user = "$email_contact";
$usersubject = "Thank You";
$userheaders = "From: xxxxx@gmail.com\n";
$usermessage = "Thank you for contact COMPANY NAME. We will reply shortly!";
mail($user,$usersubject,$usermessage,$userheaders);

if(mail($address, $e_subject, $msg, $headers)) {

    // Success message
    echo "<div id='success_page' style='padding:20px'>";
    echo "<strong >Email Sent.</strong>";
    echo "Thank you <strong>$name_contact</strong>,<br> your message has been submitted. We will contact you shortly.";
    echo "</div>";

} else {

    echo 'ERROR!';

}
Sri
  • 2,087
  • 4
  • 26
  • 50
  • You didn't mentioned what exactly problem you are facing? – Exception Sep 30 '15 at 17:14
  • Hi, I did not getting emails after click the send button. I can see the successful message but no emails. Thanks – Sri Sep 30 '15 at 17:16
  • There may be possibility that these messages are falling under spam folder ..have you checked? – Exception Sep 30 '15 at 17:21
  • Yes, I have checked and It doesn't. Thanks – Sri Sep 30 '15 at 17:22
  • Some quick questions .1. Are you sending mails from local host?. 2. Is your server supporting mail sending functionality.?. 3. For me header variables not looking in standard format .maybe you need to look into proper syntax. – Exception Sep 30 '15 at 17:32
  • I am sending mails from the server. I used to get emails from the server. Thanks – Sri Sep 30 '15 at 17:33
  • May be you need to look into headers properly. Have you tried mail just using simple mail function instead of this code – Exception Sep 30 '15 at 17:36

0 Answers0