when should be choose simple php mail and when smpt with loggin+password?

Posted by user43353 on Server Fault See other posts from Server Fault or by user43353
Published on 2011-02-16T21:31:39Z Indexed on 2011/02/16 23:26 UTC
Read the original article Hit count: 348

Filed under:
|
|
|

Hi,

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:

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

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

Thanks

© Server Fault or respective owner

Related posts about php

Related posts about email