tags:

views:

76

answers:

7

I am trying to send new system generated password using mail() in php. The thing is I am able to send it to yahoo but when I use gmail or hotmail I dont receive any emails although the function returns true. Following is the function:

if(mail($to,$subject,$body))
{
   return true;
}
else
{
  return false;
}
+2  A: 

It probably ends up in the spam folder look there. If its there make sure your email headers are perfect.

You could look into librairies for what you want to achieve. Zend_Mail has everything you could need to connect to gmail and others.

Iznogood
No it doesn't even get into spam folder.
Ajinkya
chances are you'll need to properly configure the php mail subsystem as well, avoiding spamtraps is an art unto itself.
easel
@easel especially with mail().
Iznogood
Can you elaborate it in detail ? As I am new to this
Ajinkya
A: 

Your problem might be the antispam filters. E-mails sent from PHP are usually marked as spam by the mail servers and end up deleted or in the spam can.

You can Google for "php mail spam" to get some hints of how to work around this issue.

dark_charlie
A: 

Maybe you're on a shared server and the IP is banned/blocked due to spamming by other users (websites) of your server.

Try adding SPF records.

shamittomar
+1  A: 

If you are getting the mail successfully through yahoo, you should also post the headers that are coming through from yahoo here in the question. My bet is you will need to include a "from field" also to get through on hotmail, gmail, etc...

Zak
Can you please tell me how can I post the headers, this part I have never worked before so I dont have much knowledge about it
Ajinkya
Sounds like this is a homework problem. If it is, you should have a reading list/book/handout from your prof explaining mail. If not, tell him he's a ba$#%^rd and you want your moneys worth, and you want him to explain mail to you :)
Zak
This is not a Homework problem there is a functionality to be dealt with and I have been assigned to do it. Well the email is sent if the email address is of yahoo or the university itself. It doesn't work in case of gmail or hotmail
Ajinkya
A: 

Ensure that your envelope-FROM (a.k.a. return path) is set to a valid email address that you have access to. If you're not seeing the message in the spam folders, it should be getting bounced; the bounce message may offer a clue as to why the mail is not getting through.

ngroot
A: 

I would try to include your own headers in your mail function

$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "Date: ". date('r'). " \r\n";
$headers .= "Return-Path:[email protected]\r\n";
$headers .= "Errors-To:[email protected]\r\n";
$headers .= "From:[email protected] <[email protected]>\r\n";
$headers .= "Reply-to:[email protected] \r\n";
$headers .= "Organization: YourOrg \r\n";
$headers .= "X-Sender:[email protected] \r\n";
$headers .= "X-Priority: 3 \r\n";
$headers .= "X-MSMail-Priority: Normal \r\n";
$headers .= "X-Mailer: PHP/" . phpversion();

mail($to,$subject,$body,$headers);
ken
Well I tried using the headers but I am not able to get any emails as of now. When I give an email address with .yahoo.com or with the university id it does send the email and that too it gets inside the inbox and not doesn't get spammed. But the moment I change the address to gmail or hotmail it doesn't send any email on that id.
Ajinkya
A: 

Try checking if your mailserver ip is blacklisted anywhere?

If not, try harder with the headers that are being sent with the mail.

Garis Suero