【问题标题】:In remote host: Connection could not be established with host smtp.gmail.com [Connection timed out #110]在远程主机中:无法与主机 smtp.gmail.com 建立连接 [连接超时 #110]
【发布时间】:2011-02-13 11:28:47
【问题描述】:

部署后,当我尝试发送邮件时出现以下错误:

500 |内部服务器错误 | Swift_TransportException 无法与主机 smtp.gmail.com 建立连接 [连接超时 #110] 堆栈跟踪

* at ()
  in SF_ROOT_DIR/lib/vendor/symfony/lib/vendor/swiftmailer/classes/Swift/Transport/StreamBuffer.php line 235 ...
         232.     }
         233.     if (!$this->_stream = fsockopen($host, $this->_params['port'], $errno, $errstr, $timeout))
         234.     {
         235.       throw new Swift_TransportException(
         236.         'Connection could not be established with host ' . $this->_params['host'] .
         237.         ' [' . $errstr . ' #' . $errno . ']'
         238.         );
* at Swift_Transport_StreamBuffer->_establishSocketConnection()
  in SF_ROOT_DIR/lib/vendor/symfony/lib/vendor/swiftmailer/classes/Swift/Transport/StreamBuffer.php line 70 ...
          67.         break;
          68.       case self::TYPE_SOCKET:
          69.       default:
          70.         $this->_establishSocketConnection();
          71.         break;
          72.     }
          73.   }
* at Swift_Transport_StreamBuffer->initialize(array('protocol' => 'ssl', 'host' => 'smtp.gmail.com', 'port' => 465, 'timeout' => 30, 'blocking' => 1, 'type' => 1))
  in SF_ROOT_DIR/lib/vendor/symfony/lib/vendor/swiftmailer/classes/Swift/Transport/AbstractSmtpTransport.php line 101 ...
          98.       
          99.       try
         100.       {
         101.         $this->_buffer->initialize($this->_getBufferParams());
         102.       }
         103.       catch (Swift_TransportException $e)
         104.       {
* at Swift_Transport_AbstractSmtpTransport->start()
  in SF_ROOT_DIR/lib/vendor/symfony/lib/vendor/swiftmailer/classes/Swift/Mailer.php line 74 ...
          71.     
          72.     if (!$this->_transport->isStarted())
          73.     {
          74.       $this->_transport->start();
          75.     }
          76.     
          77.     return $this->_transport->send($message, $failedRecipients);
* at Swift_Mailer->send(object('Swift_Message'), array())
  in SF_ROOT_DIR/lib/vendor/symfony/lib/mailer/sfMailer.class.php line 300 ...
         297.       return $this->realtimeTransport->send($message, $failedRecipients);
         298.     }
         299.
         300.     return parent::send($message, $failedRecipients);
         301.   }
         302.
         303.   /**
* at sfMailer->send(object('Swift_Message'))
  in SF_ROOT_DIR/lib/vendor/symfony/lib/mailer/sfMailer.class.php line 263 ...
         260.    */
         261.   public function composeAndSend($from, $to, $subject, $body)
         262.   {
         263.     return $this->send($this->compose($from, $to, $subject, $body));
         264.   }
         265.
         266.   /**
* at sfMailer->composeAndSend('tirengar@gmail.com', 'tirengarfio@hotmail.com', 'Confirm Registration', 'Hello fjklsdjf,<br/><br/> <a href="http://www.tirengarfio.com/rs5/web/frontend_dev.php/register/confirm/m/19">Click here to confirm your registration</a><br/><br/> Your login information can be found below:<br/><br/> Username: fjklsdjf<br/> Password: m')
  in SF_ROOT_DIR/plugins/sfDoctrineGuardExtraPlugin/modules/sfGuardRegister/lib/BasesfGuardRegisterActions.class.php line 89 ...
          86.       $user->getEmailAddress(),
          87.       'Confirm Registration',
          88.       $message
          89.     );
          90.   }
          91.
          92.   /**
* at BasesfGuardRegisterActions->sendRegisterConfirmMail(object('sfGuardUser'), 'm')
  in SF_ROOT_DIR/plugins/sfDoctrineGuardExtraPlugin/modules/sfGuardRegister/lib/BasesfGuard

这是我在 factory.yml 中的配置。

all:
  mailer:
    param:
      delivery_strategy: realtime
      transport:
        class: Swift_SmtpTransport
        param:
          host:       smtp.gmail.com
          port:       465
          encryption: ssl
          username:   tirengarfio
          password:   XXXX

465 端口打开了我的远程主机。本地主机没有问题。

有什么想法吗?

-- 哈维

Ubuntu 8.04

【问题讨论】:

    标签: email symfony1 smtp gmail


    【解决方案1】:

    我已直接从 gmail 网站获取这些说明。

    您必须在用户名中使用@gmail.com。

    Outgoing Mail (SMTP) Server - requires TLS: smtp.gmail.com (use authentication)
    Use Authentication: Yes
    Use STARTTLS: Yes (some clients call this SSL)
    Port: 465 or 587
    Account Name:   your full email address (including @gmail.com) 
    Google Apps users, please enter username@your_domain.com
    Password:   your Gmail password
    

    【讨论】:

    • 你可以在服务器上做以下事情吗? telnet smtp.gmail.com 465 还有你为什么要我-1?我给出了一个有效的答案。
    • 嗨@ChrisMuench,我正在使用 Laravel 5.1 并遇到类似的问题。我在我的 .env 文件中遵循了你的大纲,你能验证一下吗? drive=smtp,host=smtp.gmail.com,port=587(也试过465),encryption=ssl(也试过tls),username=me@gmail.com,password=secret,sendmail=/usr/sbin/sendmail -bs。这目前不起作用并产生:StreamBuffer.php 第 265 行中的 Swift_TransportException:无法与主机 smtp.gmail.com 建立连接
    【解决方案2】:

    你需要在防火墙上开启465

    在 CSF 防火墙上,您需要在 TCP_OUT 上添加 465 =

    【讨论】:

    • 你能告诉我们怎么做吗?
    【解决方案3】:

    我不知道这是否有帮助,购买我在本地机器 (Windows) 上运行时遇到了同样的问题。为了解决这个问题,我必须将 php 目录中的两个 dll 复制到 system32(ssleay.dll 和 libeay.dll),并在我的 apache 配置中取消注释扩展 php_openssl.dll。 linux可能有类似的解决方案。我建议您联系主机,因为您很可能无法在共享主机上执行此解决方案。

    【讨论】:

      【解决方案4】:

      好吧,我有一段时间遇到同样的问题,将:smtp.gmail.com 替换为 173.194.65.108 实际上对我有用!

      【讨论】:

      • 立即出错Connection could not be established with host 173.194.65.108 [ #0]
      【解决方案5】:

      如果您经常遇到此问题而没有任何运气,请再次检查设置。 之前忽略了自己的设置,后来发现host错了。

      我用过, smtp.google.com

      而不是 smtp.gmail.com

      太傻了,但发生在我身上。

      【讨论】:

        猜你喜欢
        • 2018-12-29
        • 2017-05-01
        • 2017-10-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-01-18
        • 2019-03-01
        相关资源
        最近更新 更多