简体   繁体   中英

php mail function not sending email to gmail account only

i am facing a weird problem in my php script. i have made a function to send email and calling the function in my php page. the function works fine when i send mail to yahoo or any other domain but fails when it comes to send mail to the gmail account.below is my code

function send_mail($p_to , $p_sub, $p_body)

{

$from = 'xxx@mydomain.com';
$to = $p_to; 
$email_subject = $p_sub;
$email_body = $p_body;

$xheaders = "";
$xheaders .= "From: <$from>\n";
$xheaders .= "X-Sender: <$from>\n";
$xheaders .= "X-Mailer: PHP\n"; // mailer
$xheaders .= "X-Priority: 1\n"; //1 Urgent Message, 3 Normal
$xheaders .= "Content-Type:text/html; charset=\"iso-8859-1\"\n";

mail($to,$email_subject,$email_body,$xheaders);

}

// when i send mail directly to a gmail account for example if a create a new page with the above code by taking hardcoded values for all the fields($p_to,$p_subject,$p_body) and sends mail then it works .

it was working fine earlier and sending mails to gmail account but, somehow stopped working for gmail.i checked the spam bucket also but found nothing. any idea frnds ???

Google marks all not verified domains as blacklisted, so your email will be directly moved to the spam box of the gmail user. I think the only thing you can do is to send a mail to the customer service of google and ask if they can verify your domain as safe, but only if you find it really important that gmail users get it in their inbox and not in their spam box.

problem was sorted out. server side modification needed.

Thanks for your replies guys :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM