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:
<?php
$to = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\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
cons:?
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('[email protected]', 'Some Sender');
$mail->addTo('[email protected]', 'Some Recipient');
$mail->setSubject('TestSubject');
$mail->send($transport);
pros:?
cons:?
Questions:
Can 1 option be filtered by gmail email server as spam?
please can you add pros + cons to options above
Thanks
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.)
Hosts that are most likely not to be sending spam meet all of these criteria:
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.