Php 使用Zend Framework发送邮件:“0”;“无法建立连接”;

Php 使用Zend Framework发送邮件:“0”;“无法建立连接”;,php,zend-framework,smtp,sendmail,Php,Zend Framework,Smtp,Sendmail,我现在正在做一个“老”php/zend项目。我在本地安装了它,除了用户填写表单后应用程序发送确认邮件的部分外,一切都很好 我的错误基本上是“无法建立连接” 代码如下: 公共函数sendMail($user,$gain=null) { 全局$config $this->_view->url = $config->app->url; $tr = new Zend_Mail_Transport_Smtp($config->app->mail->serve

我现在正在做一个“老”php/zend项目。我在本地安装了它,除了用户填写表单后应用程序发送确认邮件的部分外,一切都很好

我的错误基本上是“无法建立连接”

代码如下:

公共函数sendMail($user,$gain=null) { 全局$config

$this->_view->url   = $config->app->url;

$tr = new Zend_Mail_Transport_Smtp($config->app->mail->server);
Zend_Mail::setDefaultTransport($tr);

$mail = new MGMail($config->app->mail->key, true);
$mail->setFrom($config->app->mail->from, $config->app->mail->fromName);

if ($gain == null)
{
    $object = $config->app->mail->object->inscription;
    $render = $this->_view->render('inscription.phtml');
}
else
{
    switch ($gain)
    {
        case 'peignoir':
            $gain_name = 'un '.$gain;
        case 'casquette':
            $gain_name = 'une '.$gain;
    }

    $object = sprintf($config->app->mail->object->gain, $gain_name);
    $render = $this->_view->render($gain.'.phtml');
}

$mail->setSubject($object);
$mail->addTo($user->email, $user->first_name.' '.$user->last_name);
$mail->setBodyText($render);

$mail->send();

$this->saveSendEmail($object, $render, $user);
}

仅在my application.ini中包含“localhost”

我需要做什么来解决这个问题? 是否有要激活的php模块?
很抱歉,如果这对您来说很明显,我已经很长时间没有处理此问题了…

请确保您正在处理的计算机上本地运行SMTP服务。您可以通过在端口25上使用telnet to localhost来检查这一点:

telnet本地主机25

如果超时,则可能没有安装或运行SMTP服务器:

C:\Users\username>telnet localhost 25 连接到本地主机…无法在端口25上打开到主机的连接:连接失败

这是你的问题


要解决此问题,您需要安装并配置邮件服务器。我过去使用过hmailserver(www.hmailserver.com),它工作得很好。

本地机器是否运行SMTP服务器,服务是否正在运行?你能在SMTP端口上远程登录到本地主机吗?我刚做了:“无法建立连接”我怎么做才能激活它?我刚做了:“无法建立连接”我怎么做才能激活它?安装并配置邮件服务器,如hmailserver()配置hmailserver,使其不需要SMTP身份验证。
$config->app->mail->server