Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 113
  • Last Modified:

PHP mail() not being delivered to gmail

I have a form on a page.  when you fill out the form and confirmation email is sent to your email address.  If you have a Gmail account or if your email is routed by Gmail the mail won't arrive.  Not even in the spam folder.  Other email addresses work fine.  Has anyone ever run into this?

  $subject = 'Email Subject';

                $headers = 'MIME-Version: 1.0' . "\r\n";
                $headers .= 'Content-Type: text/html; charset=ISO-8859-1' . "\r\n";
                $headers .= 'From: rgranlund@MYSITE.com' . "\r\n";
                $headers .= 'Bcc: info@MYSITE' . "\r\n";

                mail($e, $subject, $body, $headers);

Open in new window

0
rgranlund
Asked:
rgranlund
  • 7
  • 5
  • 3
  • +2
1 Solution
 
gr8gonzoConsultantCommented:
If it's rejected, your mail service (sendmail/qmail/exim/etc) might have logs with more information on what went wrong.
0
 
Kim WalkerWeb Programmer/TechnicianCommented:
My experience has been that Gmail is the most likely to BE delivered. So it is odd that it would not be delivered to Gmail -- at least it is odd to me.

Do you have your own server or are you using a hosting/email service provider? If so, is that service provider GoDaddy?
0
 
rgranlundAuthor Commented:
Bluehost.  I have found various articles/posts where other people have had this issue but the solutions are all over the place.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Kim WalkerWeb Programmer/TechnicianCommented:
Have you checked the Spam folder?
0
 
rgranlundAuthor Commented:
@kim, that was part of my original post.  It does not go to the spam folder, it just not go. I also place a CC on the email and that one works to a non-gmail account.
0
 
Dave BaldwinFixer of ProblemsCommented:
My PHP email demo has no problem sending to Gmail.  Have you tried it?
0
 
rgranlundAuthor Commented:
@dave
Essentially it is the same.
 $headers = "MIME-Version: 1.0" . "\r\n";
                $headers .= "Content-Type: text/html; charset=utf-8" . "\r\n";
                $headers .= 'From: Rock Intuit <rgranlund@MYSITE.com>' . "\r\n";
                $headers .= 'Bcc: info@MYSITE.com' . "\r\n";

                mail($e, $subject, $body, $headers, '-f rgranlund@MYSITEt.com');

Open in new window

0
 
rgranlundAuthor Commented:
Do you think I should try phpmailer?  Cause I am having another problem on another site where the email won't go out PERIOD if I try to add anything in addition to the FROM in the headers
0
 
gr8gonzoConsultantCommented:
If you do a basic mail() call to a Gmail address without any headers, does it work?

mail("someone@gmail.com","Test Email","Test Body");

Of course, a message like this probably WILL get put into the Spam folder, but it will at least tell you whether the delivery problem has something to do with the formatting/content of your message.
0
 
rgranlundAuthor Commented:
nope.  These are not going.  They will go to a regular address but not gmail
0
 
gr8gonzoConsultantCommented:
So if the basic mails aren't going, then it's probably an issue with where you're mailing from - Gmail's probably rejecting the messages for a deeper reason.

Usually if it's not even making it to the spam folder, then it might be rejected on some other grounds. I'd start with checking your server's outgoing IP on the major blacklists:

http://www.anti-abuse.org/multi-rbl-check/

Being on a blacklist could result in the message being completely blocked (not even making it to the Spam folder).

If your server IP -is- on a blacklist...

Before you say you're not a spammer, bear in mind that if you're on a shared server or if your server's IP was previously used by someone else, you might simply have inherited the issue at no fault of your own, and it'll be up to you and the blacklists to get your IP off of them.

I'd also recommend you save a copy of one of the received emails with all of its headers intact (e.g. use Thunderbird and view the source of the message and save it all to a text file) and then attach that here.
0
 
rgranlundAuthor Commented:
Thanks for the issue.  I have another problem where another page will only send plain text.  If I add any headers it will not go out.
0
 
gr8gonzoConsultantCommented:
Is this specific to Gmail, or is it another issue entirely? If it's a different issue, I'd suggest closing this one (if it's solved) and opening a new one for the plain text message email.
0
 
Dave BaldwinFixer of ProblemsCommented:
Your two 'from' addresses don't match.  Is that an email address on that server?  That can be an issue if you are sending from a server with an email address that is not on that server.
0
 
Kim WalkerWeb Programmer/TechnicianCommented:
Some email handlers are particular about the "\r\n" between the headers when there are multiple. Some will accept just "\n", but others require "\r\n" (or is it "\n\r", I can't remember). But this will prevent the email from going out at all if it isn't correct. This is a limitation or restriction on your end, not on the recipient's end.
0
 
gr8gonzoConsultantCommented:
@Kim - It's "\r\n" - Carriage Return + New Line. A handy way of remembering the order is the phrase "Return to the Next line." Also, I agree totally with you - using \n as the line ending in mail headers can result in undesired behavior.
0
 
Ray PaseurCommented:
I have never had a problem using PHP to send email to Gmail accounts, but I have never tried to send anything arcane or incorrectly formatted.  Any malformation at all is a red flag, and is likely to cause rejection by the more sophisticated email programs.  Once a long time ago, there was such a thing as "bounced" email, but today rejection means "discarded silently" as if the email has gone into a black hole.  

If I want to send HTML email, I use (and recommend) Constant Contact.  There are competitors, of course, but CC has worked well for me over many years.
0
 
rgranlundAuthor Commented:
The code was fine. Ugggh!  The from email address had been blacklisted on a server.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 7
  • 5
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now