2
votes

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 = '[email protected]';
$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 ???

2
It might be grey-listed. For unverified domains, Gmail sometimes rejects incoming e-mail to see if the domain will try resending.George
but i am able to send the mail using hardcoded values. and how can i check to see its grey listed or not ?user2015610
It seems there is an issue with the actual values of your variables? ($p_to, $p_sub and $p_body) ?bestprogrammerintheworld
one doubt : do i need to use utf-8 charset or it does not matter to use either of them ?user2015610
@bestprogrammerintheworld : checked the values by echoing ... getting correct values.user2015610

2 Answers

0
votes

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.

-1
votes

problem was sorted out. server side modification needed.

Thanks for your replies guys :)