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:
<?php
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\"
"
. "X-Mailer: PHP/" . phpversion() . "
"
. "Reply-To: $user_email
"
. "To: $contact_email
"
. "From: $user_email
";
if (!@mail($contact_email, $subj, $msg, $head)) {
$response['error'] = 'Error send message!';
}
} else
$response['error'] = 'Error send message!';
echo json_encode($response);
die();
?>
</div>
There is no way around that and Google does it to prevent sapm. Try sending from 'noreply@yourdomain.com' with the 'reply-to' set as your gmail. youdomain should be the domain that the website you are sending from sits on.
On another note, I would also recommend using a library that wraps the mail function, take a look at SwiftMailer.