由于目标机器主动拒绝,无法建立连接


zend SMTP No connection could be made because the target machine actively refused

以下代码段:

$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('sender@test.com', 'Some Sender');
$mail->addTo('recipient@test.com', 'Some Recipient');
$mail->setSubject('TestSubject');
$mail->send($transport);

…抛出以下错误:

"No connection could be made because the target machine actively refused."

代码片段中的错误是什么?我只是从zend框架在线教程中学习的。

我们尝试将此添加到SMTP

配置中
$config = array('auth' => 'login',
'username' => 'myusername',
'password' => 'password'
'ssl' => 'ssl',
'port' => $port
);

$port可能因SMTP服务提供商而异,一般为465,但请通过SMTP服务提供商手册/帮助获取正确的端口。

希望能有所帮助