2011-03-02 160 views
0

当我尝试使用Symfony框架发送电子邮件时,出现此错误。我曾经有过这个问题,然后重新调教(隐约地),我不得不改变我的php.ini设置,并将它们匹配到我的/app/config/factories.yml以使其运行。Swift邮件和Symfony([拒绝连接#111])

不幸的是,我最近不得不重建我的机器,邮件现在已停止工作 - 不幸的是,我不记得上一次我做了什么工作。

这里是我的应用程序/配置/ factories.yml文件文件的内容片断:

all: 
    mailer: 
    class: sfMailer 
    param: 
     logging:   %SF_LOGGING_ENABLED% 
     charset:   %SF_CHARSET% 
     delivery_strategy: realtime 
     transport: 
     class: Swift_SmtpTransport 
     param: 
      host:  localhost 
      port:  25 
      encryption: ~ 
      username: ~ 
      password: ~ 

注:以上indentaion可能是错误的,由于在这个控制台被粘贴 - 不要侧跟踪。 YML在我的机器上很好。

这是记录的错误消息时,我尝试发送电子邮件:

[19-Feb-2011 14:50:13] PHP 20. userActions->executeRegisterComplete() /lib/vendor/symfony/symfony-1.3.8/lib/action/sfActions.class.php:60 
[19-Feb-2011 14:50:13] PHP 21. sfMailer->send() /path/to/actions.class.php:355 
[19-Feb-2011 14:50:13] PHP 22. Swift_Mailer->send() /lib/vendor/symfony/symfony-1.3.8/lib/mailer/sfMailer.class.php:300 
[19-Feb-2011 14:50:13] PHP 23. Swift_Transport_AbstractSmtpTransport->start() /lib/vendor/symfony/symfony-1.3.8/lib/vendor/swiftmailer/classes/Swift/Mailer.php:74 
[19-Feb-2011 14:50:13] PHP 24. Swift_Transport_StreamBuffer->initialize() /lib/vendor/symfony/symfony-1.3.8/lib/vendor/swiftmailer/classes/Swift/Transport/AbstractSmtpTransport.php:101 
[19-Feb-2011 14:50:13] PHP 25. Swift_Transport_StreamBuffer->_establishSocketConnection() /lib/vendor/symfony/symfony-1.3.8/lib/vendor/swiftmailer/classes/Swift/Transport/StreamBuffer.php:70 
[19-Feb-2011 14:50:13] PHP 26. fsockopen() /lib/vendor/symfony/symfony-1.3.8/lib/vendor/swiftmailer/classes/Swift/Transport/StreamBuffer.php:233 
[19-Feb-2011 14:50:13] Connection could not be established with host localhost [Connection refused #111] 
+3

您是否记得您的修补程序涉及在您的计算机上安装/配置邮件服务器(监听端口25)?因为看起来问题是目前没有人在那里收听...... – 2011-03-02 15:18:13

+0

这也是我的回答。安装postfix,然后再去。 – terrid25 2011-03-03 16:05:52

回答

1

的问题可能是你没有禁止在开发环境中发送邮件。你必须完成config_dev.yml这样的:

imports: 
    - { resource: config.yml } 

framework: 
    router: { resource: "%kernel.root_dir%/config/routing_dev.yml" } 
    profiler: { only_exceptions: false } 

web_profiler: 
    toolbar: true 
    intercept_redirects: true 

monolog: 
    handlers: 
     main: 
      type: stream 
      path: %kernel.logs_dir%/%kernel.environment%.log 
      level: debug 
     firephp: 
      type: firephp 
      level: info 

assetic: 
    use_controller: true 

swiftmailer: 
    disable_delivery: true 

你必须设置:

  • disable_delivery:真(不发送电子邮件)
  • intercept_redirects:真(如果你想看你的调试栏中的电子邮件)
+0

你在谈论sf2.0,他似乎使用sf1.3 – j0k 2012-06-04 22:06:09

5

我一直都很喜欢,总是有工作; 我根本不使用localhost smtp服务。

all: 
    mailer: 
    param: 
     transport: 
     class: Swift_SmtpTransport 
     param: 
      host:  smtp.gmail.com 
      port:  465 
      encryption: ssl 
      username: "[email protected]" 
      password: xxx-password 
+0

不得不自己添加加密/端口以使其可以与Mailjet一起使用 – Oliboy50 2015-07-29 13:18:04

0

我的托管服务提供商有同样的错误。我通过编辑factories.yml缩进来修复它。同时检查您的用户名/密码值。

相关问题