My Case: web application that need to send 1,000 messages per day to main gmail account.

(Only need to send email, not need receive emails - email client)

1. option - use php mail function + sendmail + config php.ini

php example:

$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

php.ini config (ubuntu):

sendmail_path = /usr/sbin/sendmail -t -i

pros:don't need email account, easy to setup


2. option - use Zend_Mail + transport on smpt+ password auto php example(need include Zend_Mail classes):

$config = array('auth' => 'login',
                  'username' => 'myusername',
                  'password' => 'password');
  $transport = new Zend_Mail_Transport_Smtp('mail.server.com', $config);
  $mail = new Zend_Mail();
  $mail->setBodyText('This is the text of the mail.');
  $mail->setFrom('sender@test.com', 'Some Sender');
  $mail->addTo('recipient@test.com', 'Some Recipient');




  1. Can 1 option be filtered by gmail email server as spam?

  2. please can you add pros + cons to options above



Both options can be filtered by Google as spam. Set Googles' Bulk Senders Guidelines.

Option 1 is simpler to setup, and won't gather a collection of undelivered messages.

Option 2 is more reliable and will gather undelivered messages along with the reason the message wasn't delivered.

EDIT: Whichever option you use, it may be best to use an authenticated connection to Gmail. (login with your credentials.)

Rules my email serves uses that Google may also apply.

Hosts which use any of the following in their HELO command are always spam. (These rules apply only to unauthenticated mail submission.)

  • An unqualified hostname (example).
  • My domain name or IP address.
  • Any other IP address (
  • A domain literal ([]).
  • An SPF record exists prohibiting use of the IP address to send email for the either: the domain in the Helo command; or the domain returned by the PTR record for the IP address.

Hosts that are most likely not to be sending spam meet all of these criteria:

  • rDNS is configured PTR ( -> A (mail.example.com) -> PTR (
  • Uses their FQDN (fully qualified domain name) in the Helo command (mail.example.com).
  • FQDN is not a second level domain (example.com).
  • FQDN has an SPF record permitting its use as a host ('v=spf1 a -all').
  • Thanks, Does gmail filter email - even not going to spam box? – Yosef Feb 16 '11 at 22:27
  • All mail servers will filter incoming email to ensure it is not Spam. Any that don't will be loaded with spam. I get spam from servers with very good reputations, but far less than I get from those with poor reputations. I'll edit to add some details. – BillThor Feb 16 '11 at 23:03
  • I make separated question for this issue:serverfault.com/questions/236482/… – Yosef Feb 16 '11 at 23:13

If you have control of the entire server hosting the domain you could check out the maillogs. Very often Google gives good feedback with a link in their rejects that tells you why it was rejected.

If you send a lot of e-mail and Google does not know you and does not have a reputation on your MTA, then they will throttle your IP address after a number of e-mails. They will continue to reject all e-mail coming from your mail server until the time has passed by.

Generally there should be no problem using normal PHP to send e-mails with.

  • in my case I send succeseful emails with php mail function to my gmail app account, until few days ago - they blocked by gmail apps. I looking what can case for that block – Yosef Feb 17 '11 at 0:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.