Tuesday, March 6, 2018

PHP's mail() function doesn't work properly

I am using PHP's mail() function to send automated e-mails from my website and while testing, I noticed that when I sent mail from website by Gmail, then e-mails sent by php mailer are generating the following warning on the recipients end: This message may not have been sent by: example@gmail.com Learn more Report phishing. But when I use other emails (like yahoo, outlook), then I got no emails in my $contact_email. Please help me to solve this problem.



** I don't want to use Google app. and my domain email address.
** I just want If someone contact (fill the form ), then I just got email in my website.
Here the code:



global $_REQUEST;
$response = array('error'=>'');


$user_name = substr($_REQUEST['user_name'], 0, 20);
$user_email = substr($_REQUEST['user_email'], 0, 40);
$user_msg = $_REQUEST['user_msg'];

$contact_email = 'contact.arefin@gmail.com';

if (trim($contact_email)!='') {
$subj = 'Message from Official Website';
$msg = "Name: $user_name

E-mail: $user_email
Message: $user_msg";

$head = "Content-Type: text/plain; charset=\"utf-8\"\n"
. "X-Mailer: PHP/" . phpversion() . "\n"
. "Reply-To: $user_email\n"
. "To: $contact_email\n"
. "From: $user_email\n";

if (!@mail($contact_email, $subj, $msg, $head)) {

$response['error'] = 'Error send message!';
}
} else
$response['error'] = 'Error send message!';

echo json_encode($response);
die();

?>



No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...