我正在使用Zend Mail发送来自Zimbra的电子邮件。
$message = new \Zend\Mail\Message();
$message->setBody("test");
$message->setFrom("febri.damatraseta@mydomainzimbra.com");
$message->setSubject("Trying to send an email");
$message->addTo("febryfairuz@gmail.com");
$smtpOptions = new \Zend\Mail\Transport\SmtpOptions();
$smtpOptions->setHost("192.123.456.789:01")
->setConnectionClass('login')
->setName('192.123.456.789:01')
->setConnectionConfig(array(
'username' => 'febri.damatraseta@mydomainzimbra.com',
'password' => '123abc',
'ssl' => 'tls'
));
$transport = new \Zend\Mail\Transport\Smtp($smtpOptions);
$transport->send($message);
我收到此错误:
Could not open socket
我安装了OpenSSL。 你能救我吗?
答案 0 :(得分:0)
几周前我遇到了同样的问题,这是正确的用法:
// Setup SMTP transport using LOGIN authentication
$transport = new SmtpTransport ();
$options = new SmtpOptions ( array (
'name' => 'whatever.com',
'host' => 'smtp',
'connection_class' => 'plain',
'port' => '587', // Notice port change for TLS is 587
'connection_config' => array (
'username' => '',
'password' => '',
'ssl' => 'tls'
)
) );
$transport->setOptions ( $options );
$transport->send ( $message );