【问题标题】:Why I cannot send email with siwapp invoicing software?为什么我无法使用 siwapp 发票软件发送电子邮件?
【发布时间】:2012-07-28 05:09:28
【问题描述】:

我已经安装了一个 siwapp 发票软件。它安装成功,但是当我尝试使用定期配置文件甚至向我的客户发送发票时,它出现了一个错误:

Warning: fsockopen() [function.fsockopen]: unable to connect to localhost:25 (Connection refused) in /home/olepress/public_html/my/lib/vendor/symfony/lib/vendor/swiftmailer/classes/Swift/Transport/StreamBuffer.php on line 233

Warning: Cannot modify header information - headers already sent by (output started at /home/olepress/public_html/my/lib/vendor/symfony/lib/vendor/swiftmailer/classes/Swift/Transport/StreamBuffer.php:233) in /home/olepress/public_html/my/lib/vendor/symfony/lib/response/sfWebResponse.class.php on line 336

Warning: Cannot modify header information - headers already sent by (output started at /home/olepress/public_html/my/lib/vendor/symfony/lib/vendor/swiftmailer/classes/Swift/Transport/StreamBuffer.php:233) in /home/olepress/public_html/my/lib/vendor/symfony/lib/response/sfWebResponse.class.php on line 357

Warning: Cannot modify header information - headers already sent by (output started at /home/olepress/public_html/my/lib/vendor/symfony/lib/vendor/swiftmailer/classes/Swift/Transport/StreamBuffer.php:233) in /home/olepress/public_html/my/lib/vendor/symfony/lib/response/sfWebResponse.class.php on line 357

我尝试搜索它,有很多与我的问题相似的问题,但我不太确定我们是否使用相同的软件。试了一下这个软件的源文件,发现这个配置文件包含:

test:
  storage:
    class: sfSessionTestStorage
    param:
      session_path: %SF_TEST_CACHE_DIR%/sessions

  response:
    class: sfWebResponse
    param:
      send_http_headers: false

  mailer:
    param:
      delivery_strategy: none

all:
  routing:
    class: sfPatternRouting
    param:
      generate_shortest_url:            true
      extra_parameters_as_query_string: true
  user:
    class: SiwappUser
    param:
      timeout:         1800
      logging:         %SF_LOGGING_ENABLED%
      use_flash:       true
      default_culture: %SF_DEFAULT_CULTURE%

#all:
#  controller:
#    class: sfFrontWebController
#
#  request:
#    class: sfWebRequest
#    param:
#      logging:           %SF_LOGGING_ENABLED%
#      path_info_array:   SERVER
#      path_info_key:     PATH_INFO
#      relative_url_root: ~
#      formats:
#        txt:  text/plain
#        js:   [application/javascript, application/x-javascript, text/javascript]
#        css:  text/css
#        json: [application/json, application/x-json]
#        xml:  [text/xml, application/xml, application/x-xml]
#        rdf:  application/rdf+xml
#        atom: application/atom+xml
#
#  response:
#    class: sfWebResponse
#    param:
#      logging:           %SF_LOGGING_ENABLED%
#      charset:           %SF_CHARSET%
#      send_http_headers: true
#
#  user:
#    class: myUser
#    param:
#      timeout:         1800
#      logging:         %SF_LOGGING_ENABLED%
#      use_flash:       true
#      default_culture: %SF_DEFAULT_CULTURE%
#
#  storage:
#    class: sfSessionStorage
#    param:
#      session_name: symfony
#
#  view_cache:
#    class: sfFileCache
#    param:
#      automatic_cleaning_factor: 0
#      cache_dir:                 %SF_TEMPLATE_CACHE_DIR%
#      lifetime:                  86400
#      prefix:                    %SF_APP_DIR%/template
#
#  i18n:
#    class: sfI18N
#    param:
#      source:               XLIFF
#      debug:                false
#      untranslated_prefix:  "[T]"
#      untranslated_suffix:  "[/T]"
#      cache:
#        class: sfFileCache
#        param:
#          automatic_cleaning_factor: 0
#          cache_dir:                 %SF_I18N_CACHE_DIR%
#          lifetime:                  31556926
#          prefix:                    %SF_APP_DIR%/i18n
#
#  routing:
#    class: sfPatternRouting
#    param:
#      load_configuration:               true
#      suffix:                           ''
#      default_module:                   default
#      default_action:                   index
#      debug:                            %SF_DEBUG%
#      logging:                          %SF_LOGGING_ENABLED%
#      generate_shortest_url:            false
#      extra_parameters_as_query_string: false
#      cache:
#        class: sfFileCache
#        param:
#          automatic_cleaning_factor: 0
#          cache_dir:                 %SF_CONFIG_CACHE_DIR%/routing
#          lifetime:                  31556926
#          prefix:                    %SF_APP_DIR%/routing
#
#  logger:
#    class: sfAggregateLogger
#    param:
#      level: debug
#      loggers:
#        sf_web_debug:
#          class: sfWebDebugLogger
#          param:
#            level: debug
#            condition:       %SF_WEB_DEBUG%
#            xdebug_logging:  true
#            web_debug_class: sfWebDebug
#        sf_file_debug:
#          class: sfFileLogger
#          param:
#            level: debug
#            file: %SF_LOG_DIR%/%SF_APP%_%SF_ENVIRONMENT%.log

我在这里错过了什么吗?我该如何解决这个问题?

【问题讨论】:

  • unable to connect to localhost:25 (Connection refused) 表示您没有在本地主机上运行邮件服务器,或者它没有监听端口 25(可能是 465 或 587)。您知道您想如何发送邮件(sendmail、本地 smtp 服务器或远程服务器)吗?
  • 对不起,我是这个问题的新手,我不明白这个过程。

标签: php fsockopen mailer


【解决方案1】:

检查该应用程序的配置:您必须配置要使用的邮件服务器(smtp 服务器)。给它使用其他软件时发送邮件的服务器的地址。

【讨论】:

  • 我已经将配置更改为正确的登录信息、主机和端口,但问题仍然存在
  • 好吧,如果您指定了另一个 smtp 服务器,但它仍然尝试连接到 localhost:25,那么您就知道去哪里找了:您的配置似乎被忽略了。没有你给出你提到的那些配置,恐怕这里没有人可以评论它。
【解决方案2】:

如果你在linux上,尝试在服务器上安装sendmail,(debian/ubuntu sudo apt-get install sendmail, (rhat/centos yum install sendmail)。

如果您有外部 SMTP 服务器(如 Gmail)或您的 ISP 的凭据,您应该能够在找到的配置文件中指定主机详细信息和凭据,请参阅sending mail in siwapp 的文档。

您可以使用类似以下配置的 SMTP:

prod:
  ...
  mailer:
    param:
      delivery_strategy: realtime
      transport:
        param:
          host: smtp.gmail.com
          port: 465
          encryption: ssl
          username: your_gmail_username@gmail.com
          password: your_gmail_password

要使用 PHP sendmail,请使用如下配置:

prod:
...
  mailer:
    param:
      delivery_strategy: realtime
      transport:
        class: Swift_MailTransport

要编辑的配置文件是siwapp/config/factories.yml

希望对您有所帮助。

【讨论】:

  • 我在共享主机上,还有可能解决这个问题吗?
  • 如果您有共享主机,那么您应该能够发送邮件。请参阅编辑后的答案并尝试仅使用 sendmail 代替。如果你愿意,你仍然可以使用 SMTP。
  • 我上面有 siwapp/config/factories.yml 配置,我不太确定把你编辑的代码放在哪里。请指教
  • 在您发布的内容的开头是mailer 部分,上面写着delivery_strategy: none,因此您可以将该部分替换为上述配置之一,可能首先尝试实时 Swift_MailTransport。
【解决方案3】:

我知道这个帖子很旧,但我终于找到了解决这个非常严重的错误的方法。

siwapp 的安装说明有点……有点小,很难获得完整的画面。我同时整理了这些笔记

将 factory.yml 文件复制到您的配置文件夹

cp <siwapp_root>/apps/siwapp/config/factories.yml <siwapp_root>/config/factories.yml

因此修改您的产品部分

prod:
  ...

  mailer:
    param:
      delivery_strategy: realtime
      transport:
        param:
          host: smtp.gmail.com
          port: 465
          encryption: ssl
          username: your_email_address@gmail.com
          password: your_password

替换地址和密码的值。

清空 /cache/* 处的缓存(但不要删除目录本身!)以删除旧配置。不过我之前遇到过这个问题,所以最好建议您备份缓存目录...

tar -czf siwappcachebkp.tgz <siwapp_root>/cache/*

如果由于某种原因重建缓存失败,要手动配置邮件,你需要专门修改这个文件:

<siwapp_root>/cache/siwapp/prod/config/config_factories.yml.php

在文件末尾,您会发现硬编码为映射的邮件连接详细信息;输入正确的值,一切顺利。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-14
    • 2018-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-07
    • 1970-01-01
    相关资源
    最近更新 更多