tags:

views:

545

answers:

5

I have a small email confirmation form. I was testing it and everytime I enter my email and go to verify it, it's in the spam box. I have tested it with multiple accounts and getting complaints about this issue as well.

When I login to my domain's mailbox and send emails to my users, they go straight to the inbox....

what is wrong with php's mail() ? I have checked my server's ip to see if it was blacklisted and its not. Also the domain is very generic like welcometomysite

Just want to add that I host 2 other domains on the same dedicated server using the same ip.

A: 

You've got to be more specific if you want the question answered. Some things to check: is your IP set correctly? Is the From address matching that IP? PHP's mail() is in general rather terrible for actually sending email. Also, check your config file --- usually, default From fields and such live in there.

pavpanchekha
+2  A: 

We have faced this problem in past so instead of trying to figure out as to why part we adopted PHP Mailer and used SendMail functionality as exposed by its classes.

Check out PHPMailer

Yogi Yang 007
+2  A: 

You should Google for something called an MX record. Your private emailis sent through the host's server with it's domain name and a searchable MX record. PHP mail() however will send from the server where the file is located. This is usually a server with a different IP, an IP without a domainname attached to it. This is usual the case if you're on a shared host.

The email you send from php mail() is from a domain, but the IP doesn't point to that domain. Furtermore there is no (or a wrong) MX record for the IP and an exdisting (or wrong) mX record for the domain it's supposed to be sent from. This triggers spamfilters.

I hope this makes sense, but do read some articles on Wikipedia or so.

Try using a php package to send mail like PHPMailer or Swiftmailer to send the mails from.

Afwas
+1  A: 

Indirect answer:

We signed up with Jango Mail, who has an authenticated SMTP relay, and awesome deliverability. It costs a little bit of money, but is well worth it.

http://www.jangosmtp.com/

gahooa
A: 

To get past the spam filters generally (providing there are no blacklist or other more obvious issues), you need to make sure the envelope-from matches the from you are setting.

Use the following code:

$headers .= "From: Some Name<$from>\r\n";
$envFrom = '[email protected]';
mail($to, $subject, $body, $headers, $envFrom); 

There does not need to be a space between the -f and the email address. I have seen reports that a space will break it, so my recommendation is to not put one there to be on the safe side.

All in all it would be better to use PHPMailer or Jango Mail as recommended as there are other features that make mailing much less painful, but this will get you going in the meantime.

Joseph