【问题标题】:Send mails with a rails app使用 rails 应用程序发送邮件
【发布时间】:2012-02-11 00:13:37
【问题描述】:

我的 webapp 在 ubuntu 服务器上运行在 Rails 3.0.3 和 MySQL 上。

我想从我的网站发送邮件。在网络服务器上,我安装了 postfix。我可以用命令行发送邮件。

我在环境中的所有 .rb 文件都有以下几行:

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.perform_deliveries = true

  config.action_mailer.smtp_settings = {
  :address              => "localhost",
  :port                 => "25",
  :domain               => 'mydomain.com'
  }

当我从 Rails 控制台发送邮件时它不起作用,它说它发送了一封邮件,仅此而已:

=> #<Mail::Message:83356150, Multipart: false, Headers: <From: Some One <someone@mydomain.com>>, <To: my@mail.com>, <Subject: sending mails!>, <Mime-Version: 1.0>, <Content-Type: text/plain>>

\var\log\mail.log 中没有踪迹,rails 应用的 log/test.log 中没有踪迹。

我不知道该去哪里。这是我的rails配置吗?是我的后缀吗?是网络问题吗?

我只想从 webapp 发送邮件,所以我尝试使用 sendmail,但它也不起作用。

编辑:在我的开发环境中,我的日志中有关于邮件的跟踪:

Rendered notifier/email.text.erb (7.3ms)

启动正确的控制台(rails c 测试)我可以在我的测试环境中找到相同的跟踪。但是我的 postfix 日志仍然没有被 rails 影响...

【问题讨论】:

    标签: ruby-on-rails email postfix-mta


    【解决方案1】:

    检查config/environments/development.rb(我认为是目录)。

    确定

    config.action_mailer.perform_deliveries = true 
    config.action_mailer.raise_delivery_errors = true
    

    这些将覆盖 config/environment.rb 中的设置

    【讨论】:

    • 已在使用该文件夹。 Mais 设置在 test、develop 和 production.rb 中。尽管引发错误,log/test.log 仍然为空。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-10-01
    • 2016-11-06
    • 2014-08-11
    • 2014-07-28
    • 1970-01-01
    • 2015-07-31
    相关资源
    最近更新 更多