我使用 ZF2 的 Message 类来尝试发送电子邮件。但是,执行下面的代码后,页面尝试重定向,大约一分钟后给我一个“本地主机已超时”错误。有任何想法吗?
$message = new Message();
$message->addTo('ToEmail@gmail.com')
->addFrom('FromEmail@gmail.com')
->setSubject('Greetings and Salutations!')
->setBody("Sorry, I'm going to be late today!");
// Setup SMTP transport using LOGIN authentication
// Setup SMTP transport using PLAIN authentication over TLS
$transport = new SmtpTransport();
$options = new SmtpOptions(array(
'name' => 'localhost',
'host' => 'localhost',
'port' => 8888, // Notice port change for TLS is 587
'connection_class' => 'plain',
'connection_config' => array(
'username' => 'FromEmail@gmail.com',
'password' => 'FromPassword',
'ssl' => 'tls',
),
));
$transport->setOptions($options);
$transport->send($message);