GMAIL blocking all PHP sent mail

I NEED automated mail to go through to my GMAIL users when sent with PHP mail scripts, however every time they are moved to the SPAM folder in gmail.

I am aware that they can manually go in and find the message, but i dont want to have to tell hundreds of users to do that…

Has anyone managed to make a mail script that will actually be accepted by GMAIL / HOTMAL / etc. ?

maybe you are using normal mail() function.

you can try to use PHPMail class. It is not bad. You need to provide a valid SMTP server, username and password.

check this

Save [color=#CC0000]$97[/color] (max discount) on dreamhost plans by using promo code: [color=#CC0000]97CRAZY[/color]. Sign Up NOW

tried the phpmailer and still my mails went directly to GMAIL spam box. tried SMTP, mail(), phpmailer, pretty much everything I can think of…

does anyone actually have this working from a Dreamhost account?

I know this might seem obvious, but I just wanted to verify…

Have you checked the e-mail that is being generated? Is there anything that Gmail’s spam filter would object to? Who the e-mail is from, title of the e-mail, content… whatever else?

Rather than being about Gmail blocking mail from Dreamhost, I wonder if it might be Gmail blocking your specific automated e-mails. Because usually when e-mail servers take issue with other domain’s e-mail, it just bounces it, not flags it as spam.

Just my two cents.

yer thanks for the suggestion, but thats not the case.

I get the same result for many different kinds of email.

also the identical email sent manually got through ok.

Mine all work fine. But I have Sender Policy Framework records on my domains as well.

can you please tell me how you made your SPF’s work? I tried but I have no idea how to do it… I would really appreciate your help!

Actually, suddently SPF is also working on my mails too…

Received-SPF: pass ( domain of designates as permitted sender)

HOWEVER, its still getting caught by my gmail account as spam…

TEZ - please try sending an automated mail to and ill see if it gets through ok. And if so please please please tell me your setup - this is really holding me back at the moment :frowning:

First i’d just stat unblocking them. But here’s my SPFs. It will take a while to update though, day or two.

v=spf1 a mx -all

v=spf1 a mx ptr ~all

this is what im using, still blocked by GMAIL

I just put this on a test page, loaded the page, and the mail went right into my gmail inbox. Leave what’s in bold, change what’s in italics.

mail('’, ‘Subject Line’, ‘Message body.’, null, '’);

I’d guess that it’s either your content, or maybe your specific server IP that’s triggering it.

:stuck_out_tongue: Save up to $96 at Dreamhost with ALMOST97 promo code (I get $1).
Or save $97 with THEFULL97.

Hello and thank you very much for your reply.

I tried it but still went to junk folder.

I suspect you have recieved many mails from yourself in the past, and so GMAIL now trusts your domain, as I get successful mails when sending to a GMAIL account that already ‘trusts’ - HOWEVER, when i create a brand new gmail account, the mail goes straight to SPAM.

This is a problem since my account activation system will be mailing many people for the first time!

If you wouldnt mind, could you please try sending me a mail to with your automated script thing - if it comes to my inbox, i know its a problem with my account…

just try again with this code.

mail($to_email_address, $message, $subject, “X-Mailer: PHP/” . phpversion() . “\r\n Reply-To: $from_email_address”, “-f From: $from_email_address”);

Save [color=#CC0000]$97[/color] (max discount) on dreamhost plans by using promo code: [color=#CC0000]97CRAZY[/color]. Sign Up NOW

tried and failed. If you think you have yours working, please use it to send a mail to and I will know for sure that it works

Thank you!

hmm… the mail from YapAuction (thank you very much) came through fine by using the phpmailer class instead of standard PHP mail function.

I cannot even get PHPMAILER to send mail - every time it says “Error From mail failed” or something… it never works :frowning: please give me the function that you use to send mail successfully.

Also, looking at the headers of a recieved mail in to GMAIL, why is the message received 3 times from different mail servers?

Received: by with SMTP id 14cs56092wxr;
Sat, 3 Mar 2007 22:44:13 -0800 (PST)
Received: by with SMTP id x14mr10468703pyi.1172990653116;
Sat, 03 Mar 2007 22:44:13 -0800 (PST)
Received: from ( [])
by with ESMTP id 7si6726013nzo.2007.;
Sat, 03 Mar 2007 22:44:13 -0800 (PST)
Received-SPF: pass ( domain of designates as permitted sender)
Received: from ( [])
by (Postfix) with ESMTP id 12CBF2FBC3
for; Sat, 3 Mar 2007 22:44:12 -0800 (PST)
Received: from ( [])
by (Postfix) with ESMTP id 03540EE23C
for; Sat, 3 Mar 2007 22:44:12 -0800 (PST)
Received: by (Postfix, from userid 729925)
id 051A8DCDEC; Sat, 3 Mar 2007 22:44:12 -0800 (PST)
Subject: - Japans fastest growing community
MIME-Version: 1.0
Content-type: text/plain; charset=utf-8
From: oldSushi
X-Mailer: PHP v4.4.4
Date: Sat, 3 Mar 2007 22:44:12 -0800 (PST)

I’m glad that PHPMailer is working.

I’ve uploaded a sample code to my server. You can download it from here

Remember to use valid smtp server name, valid user name and password. I used yahoo smtp server to send you the email last time.

Save [color=#CC0000]$97[/color] (max discount) on dreamhost plans by using promo code: [color=#CC0000]97CRAZY[/color]. Sign Up NOW

I hate to resurrect this post from the dead, but I also hate to start a conversation that’s already been started…Has anyone ever found a solution to this “straight to spam folder” issue? I’m having the problem with my new Gmail account, so I’d appreciate ANY help anyone can offer! Thanks in advance!!

I just tested an osTicket installation and left the default (which doesn’t exist) as the email handling account and all mail is going directly to inboxes at GMail using the server’s standard mail() function. Having said that, the above domain’s mail is set up as “GMail Hosted”, so perhaps GMail are allowing it through as legit via some wildcard setup or somesuch.


Email is being sent to GMail via Blingy in the above case.

Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost