我正在尝试在社交引擎控制器中设置我自己的发送邮件功能。失败没有错误。请帮忙!
以下是我用来发送邮件的代码。我把它放在分类索引控制器里面。
use Zend\Mail\Message;
use Zend\Mail\Transport\Smtp as SmtpTransport;
use Zend\Mail\Transport\SmtpOptions;
$message = new Message();
$message->addTo('to@email.com')
->addFrom('from@email.com')
->setSubject('Greetings and Salutations!')
->setBody("Sorry, I'm going to be late today!");
// Setup SMTP transport using LOGIN authentication
$transport = new SmtpTransport();
$options = new SmtpOptions(array(
'name' => 'localhost.localdomain',
'host' => 'smtp.mandrillapp.com',
'port' => '587',
'connection_class' => 'login',
'connection_config' => array(
'username' => 'my@email.com',
'password' => '*********',
),
));
$transport->setOptions($options);
$transport->send($message);
谢谢!