2012-08-01 67 views

回答

2

這裏是通過SSL選項來SmtpOptions類的例子:

use Zend\Mail\Transport\Smtp as SmtpTransport; 
use Zend\Mail\Transport\SmtpOptions; 

// Setup SMTP transport using LOGIN authentication 
$transport = new SmtpTransport(); 
$options = new SmtpOptions(array(
    'name'    => 'localhost.localdomain', 
    'host'    => '127.0.0.1', 
    'connection_class' => 'login', 
    'connection_config' => array(
     'username' => 'user', 
     'password' => 'pass', 
     'ssl'  => 'tls', // can use tls or ssl 
    ), 
)); 
$transport->setOptions($options); 
$transport->send($message); 

希望有所幫助。