Free Web Hosting Forum
Web hosting
Go Back   Free Web Hosting Forum > Website Building > Web Programming
Reload this Page PHP mail() not delivering to gMail/Google Apps
Reply
 
Thread Tools Display Modes
(#1)
Old
doctorcolossus doctorcolossus is offline
Junior Member
doctorcolossus is on a distinguished road
 
Posts: 24
Join Date: Dec 2008
Question PHP mail() not delivering to gMail/Google Apps - 07-23-2009, 02:19 AM

I seem to be able to send mail without any trouble to any other server. I've tested with e-mail accounts I have at nerdshack.com, lavabit.com, and mail.az, and via forwarders footbag.org, e4ward.com, and tempomail.fr. However, e-mails sent to my Google Apps' account, at my own domain, never arrive (nor do I see them in the 'Spam' folder).

This is a problem, because various scripts at my domain are designed to send user notifications, and all user accounts have e-mail under our domain through Google Apps!

One of the first things I thought of to troubleshoot was to attempt to receive bounce messages in order to diagnose what might be going on. But apparently I can't change this. I attempt to add "Return-Path: Free School Denver Webmaster <[mydomain]>\r\n" to my headers, but the e-mails I receive through the aforementioned accounts look like this:

Code:
Return-Path: <nobody@srv15.000webhost.com>
...
Received: from srv15.000webhost.com (server15.000webhost.com
X-PHP-Script: [mydomain].org/rsvp.php for [mydomain]
From: Web-Site <[mydomain]@[mydomain].org>
Reply-To: Webmaster <[mydomain]@[mydomain].org>
So is there no way to change the bounce address from nobody@srv15.000webhost.com? If that's the case, maybe somebody at 000webhost can forward these bounces to me?

I read about one other guy having problems using e-mail forwarding through 000webhost to gMail, but has anyone else experienced this issue with PHP's mail() failing to deliver to gMail/Google Apps mail?

I've been trying to get bottom of this problem for over a month and have pretty much exhausted my ingenuity. I sent a message to Google Saturday, but haven't received any reply yet. I haven't submitted a ticket with 000webhost yet.

Thanks for any that you can supply!
Doctor Colossus

Last edited by doctorcolossus; 07-29-2009 at 07:25 AM.
Reply With Quote

(#2)
Old
douglasheriot's Avatar
douglasheriot douglasheriot is offline
Junior Member
douglasheriot is on a distinguished road
 
Posts: 5
Join Date: Jul 2009
Location: Australia
Default Check the DNS - 07-25-2009, 10:41 AM

I've had the problem a while ago too. I just got over it, by just using a separate regular GMail address instead of my personal Google Apps one.

But then, I got reports of other people not being able to send emails to my Google Apps address as well. This was bad, so I had to go back to fix the problem. They said something about trying to send it to an address @server8.000webhost.com, and I had no idea how these other people got that address.

My DNS is with Namecheap.com —*not with 000webhost.com, so I have more control (and can move it when my site is down… like now). I used a CNAME host record to server8.000webhost.com, instead of an A Address like I should have (to the IP). Apparently, using a CNAME will confuse some email servers, so they send mail to the CNAMEs mail server, and ignore the MX records (which point to Google Apps)


In summary… make sure your DNS uses an A record, and not a CNAME, otherwise some servers may ignore the MX records that point to Google Apps.
Reply With Quote
(#3)
Old
rudy3107 rudy3107 is offline
Junior Member
rudy3107 is on a distinguished road
 
Posts: 13
Join Date: Jul 2009
Default 07-25-2009, 02:22 PM

May be your php mail header is wrong which google discard or its not going out from your email script itself.

try to add sender email in google apps.
Reply With Quote
(#4)
Old
doctorcolossus doctorcolossus is offline
Junior Member
doctorcolossus is on a distinguished road
 
Posts: 24
Join Date: Dec 2008
Default 07-28-2009, 06:04 AM

Thanks to both of you for those suggestions! I still haven't gotten to the bottom of this, and thought I would follow up about your ideas.

DouglasHeriot wrote:
Quote:
My DNS is with Namecheap.com —*not with 000webhost.com
My situation is the same -- I use name.com's DNS services.

DouglasHeriot wrote:
Quote:
In summary… make sure your DNS uses an A record, and not a CNAME, otherwise some servers may ignore the MX records that point to Google Apps.
This seems like excellent advice, but I'm a unclear about the particulars. I have two A records, one for [mydomain].org and another for *.[mydomain].org, both pointing to the IP address of server15. I have MX records pointing to aspmx.l.google.com, alt1.aspmx.l.google.com, alt2.aspmx.l.google.com, aspmx2.googlemail.com, aspmx3.googlemail.com, aspmx4.googlemail.com, and aspmx5.googlemail.com, in order of descending priority. Do you mean that I need to use A records for my mailservers?

I noticed I had an SPF record set to "v=spf1 a mx ~all" -- I think I had gotten that previously from Google, but their help page now states:
Quote:
To set your domain's SPF record, you should have access to your domain's DNS settings. On your DNS resource, publish the following TXT record: v=spf1 include:aspmx.googlemail.com ~all

Note: Publishing an SPF record that lacks include:aspmx.googlemail.com or specifying -all instead of ~all may result in delivery problems.
But an article entitled Google Provides Incorrect SPF Record Info for Use with Google Apps states:
Quote:
If you’re using SPF Records with email powered by Google Apps, you most likely have a problem — a BIG one. Your email is likely getting flagged as spam, and not getting to important recipients. The (incorrect) SPF Record recommended by Google is:

v=spf1 include:aspmx.googlemail.com ~all

Unfortunately due to a problem with how Google is routing email internally, this WILL cause your outgoing emails to be flagged as spam, even when being read by another Google-based account. Great…thanks, Google!

From tests I’ve run, I can confirm that it happens when you are using POP and emailing through a client like Outlook, Thunderbird, etc. I haven’t tested it with IMAP. However, it doesn’t seem to flag anything as spam when the web interface is used.

According to the Google help forums, there is a workaround that will keep your emails from being flagged as spam... However, in my opinion this isn’t a complete solution because it doesn’t allow mail sent from your webserver. I recommend using:

v=spf1 a mx include:aspmx.googlemail.com include:_spf.google.com ~all

This will allow mail from your webserver (for example if you have a contact form), and it also will keep you from having to change the SPF Record if Google ever fixes Google Apps to function the right way (as far as mx records are concerned). If you don’t have a dedicated IP on your server, or you don’t need to send mail from it, then you may want to delete the “a” between the “v=spf1″ and the “mx”.
So I've changed mine to "v=spf1 a mx include:aspmx.googlemail.com include:_spf.google.com include:srv15.000webhost.com ~all", in accordance with that advice and in order to include mail originating from the appropriate server at 000webhost. However, I'm under the impression that an incorrectly-configured SPF record could only hinder mails being sent from addresses claiming to originate at my domain -- I've tried using mail() with and without "Return-Path: ", "From: ", and "Reply-To: " headers, so I'm doubtful that the SPF record could have caused my trouble. But I suppose time will tell, when my DNS changes propogate... On the other hand, perhaps this will finally allow me to receive bounces and see what might be wrong.

I also removed some superfluous CNAME records I had: one which I had long-ago set up for Google Apps' one-time proof-of-ownership validation, and others pointing from mail.[mydomain].org and start.[mydomain].org to ghs.google.com, which hadn't been working anyhow on account of my *.[mydomain].org A record. I'll report back in a couple of days if these changes solve the problem, but I'm skeptical. Does anyone notice anything wrong with my DNS configuration?

Quote:
A *.[mydomain].org 64.235.57.62
A [mydomain].org 64.235.57.62
MX [mydomain].org alt1.aspmx.l.google.com 20
MX [mydomain].org alt2.aspmx.l.google.com 20
MX [mydomain].org aspmx.l.google.com 10
MX [mydomain].org aspmx2.googlemail.com 30
MX [mydomain].org aspmx3.googlemail.com 30
MX [mydomain].org aspmx4.googlemail.com 30
MX [mydomain].org aspmx5.googlemail.com 30
TXT [mydomain].org v=spf1 a mx include:aspmx.googlemail.com include:_spf.google.com include:srv15.000webhost.com ~all
rudy3107 wrote:
Quote:
May be your php mail header is wrong which google discard or its not going out from your email script itself.
I had considered that, but my mail doesn't seem to arrive at Google Apps addresses at my domain whether or not I include any headers at all in that optional argument of mail(). Moreover, every other server I've sent test messages to accepts them (I pasted headers from a message I received this way in my original post above)... So I don't have any clues what I could be doing wrong. Do you know of any common problems with headers that could cause this problem, or headers which are necessary to include in order to get Google Apps to accept messages?

rudy3107 continued...
Quote:
try to add sender email in google apps.
I tried adding nobody@srv15.000webhost.com to my contact list under my own user account in Google Apps for my domain, but it didn't do the trick. I don't think that's the problem though, because then I would at least be seeing these messages in my 'Spam' box. Even if it were, I don't think it would be possible for me to do that under each of my users' accounts, since each of them has their own login to Google Apps for our domain... (unless I reset all of their passwords, which would be very time-consuming for me to do that for each of them, log in to each of their accounts, add that contact, advise them to choose a new password, etc... not to mention the inconvenience for all of my users). Is that what you meant, or is there some way to do this domain-wide under "Manage this domain" that I'm missing?

Last edited by doctorcolossus; 07-28-2009 at 06:09 AM.
Reply With Quote
(#5)
Old
douglasheriot's Avatar
douglasheriot douglasheriot is offline
Junior Member
douglasheriot is on a distinguished road
 
Posts: 5
Join Date: Jul 2009
Location: Australia
Default 07-28-2009, 06:20 AM

Your DNS looks fine:

Quote:
A *.[mydomain].org 64.235.57.62
A [mydomain].org 64.235.57.62
MX [mydomain].org alt1.aspmx.l.google.com 20
MX [mydomain].org alt2.aspmx.l.google.com 20
MX [mydomain].org aspmx.l.google.com 10
MX [mydomain].org aspmx2.googlemail.com 30
MX [mydomain].org aspmx3.googlemail.com 30
MX [mydomain].org aspmx4.googlemail.com 30
MX [mydomain].org aspmx5.googlemail.com 30
TXT [mydomain].org v=spf1 a mx include:aspmx.googlemail.com include:_spf.google.com include:srv15.000webhost.com ~all

All I was saying was make sure you didn't have this:

Quote:
CNAME *.[mydomain].org srv15.000webhost.com
CNAME [mydomain].org srv15.000webhost.com


Here's the SPF records I use:

Quote:
spf2.0/pra include:aspmx.googlemail.com include:douglasheriot.com ~all
v=spf1 include:aspmx.googlemail.com include:douglasheriot.com ~all.
I don't really know much about these. I just remember I used an online generator somewhere to get them.


Maybe if you tried changing it to include your domain, instead of just srv15.000webhost.com?

Maybe you could try just getting rid of the SPF record completely, as you shouldn't really need it (unless people were sending fake emails from your domain)

Last edited by douglasheriot; 07-28-2009 at 06:21 AM. Reason: nicer formatting
Reply With Quote
(#6)
Old
doctorcolossus doctorcolossus is offline
Junior Member
doctorcolossus is on a distinguished road
 
Posts: 24
Join Date: Dec 2008
Default 07-29-2009, 07:56 AM

I still haven't found a solution, but tried the experiment today of using tempomail.fr to create a forwarding address to my Google Apps address. The e-mail I sent to that address went through and arrived directly in my Google Apps inbox. So I think that debunks the theory that there might be something awry in the headers that mail() is generating.

I read a thread today at the Site5 hosting forums entitled "How To: Configure your DNS to use Google Apps email!", in which a guy seemed to be having a very similar problem to mine:
Quote:
I created a hosting account for a domain and set up MX records to point to Google Mail as described above. Mail is routing correctly to GMail from the internet at large, but mail originated on my Site5 server (either from the box itself or using my Site5 account for SMTP) is attempting delivery locally and bouncing.
The first reply was this:
Quote:
When your site sends mail it sends it via the smtp server on that box, which thinks its the endpoint for that domain. You need to mail support and ask the to move you domain to the remotehosts file.
This also jives somewhat with my problem. My new theory is that 000webhost's SMTP server isn't correctly dispatching e-mails sent to my domain externally as it ought to; and that it believes itself to be the endpoint for my domain. Any ideas about that?

I just opened a ticket:
Quote:
The mail() function will not send messages to any e-mail address at my own domain; it works fine with addresses at any other domain. I host my e-mail through Google Apps, and my DNS records with my registrar (name.com). I've been trying to troubleshoot the problem for over a month to no avail, so I appeal to your succor.

My most recent theory is that srv15.000webhost.com thinks that *it* is the endpoint for my domain -- perhaps it should be added to your SMTP server's remotehosts?

Some further background on my problem can be found at this thread in the forum.
I immediately received the reply:
Quote:
I'm very sorry, but we do not provide website development and script debugging services. We are happy to answer all questions related to our servers, but we only provide web hosting service, and we do not experience in building websites. We prefer spending our time to keep servers in perfect condition.

This question is not related to hosting servers, so we could not provide an answer for you.

However, you can always ask for professional support and assistance at Fix My Script ( http://www.fixmyscript.com/ ). Their experienced staff will solve this problem instantly, so you can save your time and enjoy improved website in minutes.
]-:<
Reply With Quote
(#7)
Old
doctorcolossus doctorcolossus is offline
Junior Member
doctorcolossus is on a distinguished road
 
Posts: 24
Join Date: Dec 2008
Default 07-29-2009, 08:47 AM

Yes, I'm more and more convinced that this is the problem:

Google Apps Admin Help: Using a web form to deliver mail
Quote:
If you have a form (using PHP/ASP/etc) on your website that is configured to send a message to your Google Apps email account, but you never receive mail from your website's form, please perform the following tests:

* Send a message to your Google Apps email account from a non-Google Apps personal email account.
* Modify the form to send mail to your Gmail account, or another non-Google Apps personal email account.

If both tests are successful, this issue is most likely caused by mail delivery settings on your webserver. Because your website and your Google Apps email address share the same domain name, the mail agent running on the server that hosts your website thinks that it is responsible for mail addressed to your domain name. This is a typical default setting.

When someone submits the form on your website, the mail agent recognizes your domain name and concludes that it should be sending mail to itself. The mail agent will attempt to deliver the message locally.

To resolve this issue, notify the mail agent running on the server that hosts your website that it is not also responsible for handling mail for your domain. Contact your web host for specific instructions. If you host your own website, contact the support team for your mail server software.
Both tests succeeded for me, as I told previously. Now I just have to figure out how to resolve the issue...

WebHostingBuzz: PHP Mailer and google apps with mx records changes
Quote:
The domain should be removed from localdomains in order that mail addressed to recipients at that domain will be sent out from the server. Otherwise, exim will deliver mail to that domain "internally" without leaving the server. As your mailboxes are at Google, the recipients would not receive that mail.
In the beginning of that thread, there's talk of a way to do this through a CPanel option called "Always accept mail locally". I don't see anything like that in 000webhost's CPanel interface though.
Reply With Quote
(#8)
Old
doctorcolossus doctorcolossus is offline
Junior Member
doctorcolossus is on a distinguished road
 
Posts: 24
Join Date: Dec 2008
Default 07-29-2009, 07:21 PM

Well, the support ticket worked out like this:

Myself:
Quote:
Thanks for your quick reply, but this question is indeed related to your hosting servers.

I don't need any help with my script -- as I said, the mail() function is working correctly for me in other circumstances, and is even returning TRUE for success in this case. It seems that messages I send to addresses at my own domain aren't being dispatched externally by your SMTP server.
Support:
Quote:
I am sorry, but we are unable to give you resolution on this ticket now. Resolving problem listed on this ticket would require a lot of administrative time form us and we are limited in staff that works on this free web hosting platform. We can only advise you upgrade account from http://www.000webhost.com/upgrade and you will be moved to our paid hosting platform, where we have much more staff members available and you will receive VIP attention you deserve. We will help you will any problems you experience. We are sorry for inconveniences and thanks for understanding.
<rant>

I try not to expect much from support for a free hosting service, but it doesn't seem like this would be so difficult to check out. I spent a huge amount of time troubleshooting all possible issues on my end before contacting support, and now I'm pretty sure this is an issue that only support can solve for me. When I originally signed up here I thought the support was pretty good. I suppose it could be that my requests are becoming more complicated, but it seems like during the past year their service has been getting worse and worse and that, before even reading one's problem, they are trying to think of an excuse to reject it.

I looked at several workaround options yesterday, including SwiftMailer, PEAR, and a custom script to send mail through via SMTP using fsockopen(). None of these worked out, so it seems like my only options are to:
1) live without the essential functionality of being able send mail to my own users via forms;
2) hack 000webhost's server, and fix the problem myself; or
3) change hosts

Number three seems to be the least-unappealing option, so I guess I'll do that. If you're curious about why I won't upgrade to the paid service, I'm developing a site for a non-profit organization for free, out of the kindness of my heart; and I'm unemployed right now, and don't have money of my own to put forth on top of the time I'm sacrificing.

So I guess this is goodbye. ::sniffle::

</rant>
Reply With Quote
(#9)
Old
douglasheriot's Avatar
douglasheriot douglasheriot is offline
Junior Member
douglasheriot is on a distinguished road
 
Posts: 5
Join Date: Jul 2009
Location: Australia
Default 07-29-2009, 11:26 PM

or…

4) Create a normal gmail account @gmail.com that will forward the emails to your Google Apps account. (that's what I've been doing for a while).
Reply With Quote
(#10)
Old
doctorcolossus doctorcolossus is offline
Junior Member
doctorcolossus is on a distinguished road
 
Posts: 24
Join Date: Dec 2008
Default 07-30-2009, 07:27 AM

Thanks once again for your cleverness, Douglas (it does clear up my confusion about how you had gotten this working, whereas I couldn't. I'm glad to know that I wasn't the only person unable to solve this issue at its core.) I did in fact consider something like that too; the problem in my case is that my forms aren't just used to e-mail me, or any one, single person.

To tell you a bit more about my site, it's for a free school where community members hold free classes on a variety of topics. One of the main functions of the site, as I envisioned and coded it, is to allow for RSVPs to classes and events. E-mail notifications are then theoretically/ideally sent to a teacher when someone RSVP's to their class. All teachers have e-mail addresses at my domain and, since these volunteers come and go frequently, it's important that the system be extensible for any number of new users. I can't take the time to create a unique forwarding address for each one -- it would be a pain. As it is I've been having all of these notifications sent to my own personal inbox and forwarding them manually as appropriate. This is also a pain, and prone to error on my part if I miss something (which I already did).

I intend to switch my hosting to HostHelpers later today. I think I'll miss 000webhost -- it was fairly reliable and in most ways quite good.

<more whining>However, the support is a joke and in a case such as this, where I actually need support, I'm left high & dry. They won't respond to any inquiry that could possibly involve a minute action, analysis, or original thought on their part. It seems to me like they'd might as well not exist if their entire role is to issue generic responses about how it's not possible to help people.</more whining>
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com