Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 电子邮件不出去_Ruby On Rails_Ruby - Fatal编程技术网

Ruby on rails 电子邮件不出去

Ruby on rails 电子邮件不出去,ruby-on-rails,ruby,Ruby On Rails,Ruby,我想从我的ruby应用程序生成电子邮件,所以我使用了ActionMail类 我在environment.rb上配置了电子邮件设置。我的配置如下 ActionMailer::Base.raise_delivery_errors = false ActionMailer::Base.delivery_method = :smtp ActionMailer::Base.smtp_settings = { :address => "mail.authsmtp.com", :port

我想从我的ruby应用程序生成电子邮件,所以我使用了ActionMail类

我在environment.rb上配置了电子邮件设置。我的配置如下

ActionMailer::Base.raise_delivery_errors = false
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
    :address => "mail.authsmtp.com",
    :port => 2525,
    :user_name => "*******",
    :password => "*******",
    :authentication => :login
}
我的mailer模型是TestMailer,所以我决定检查邮件操作,以便在TestMailer.rb上定义方法

def  test_mail(to) {
    subject "My first email!"
    recipients "#{to}"
    from 'test'
    charset "utf-8"
    content_type 'text/html'
    body "Testing one two three..."
}
我打开ruby脚本/控制台,通过
TestMailer调用test\u-mail方法example@gmail.com)

它没有生成电子邮件。在应用程序服务器日志中,其将生成电子邮件模板。

我不知道这里有什么问题。

您应该检查config/environments/development.rb | test.rb | production.rb (取决于您启动控制台的方式)

并验证它是否未覆盖您在environment.rb中的smtp设置。如果您运行以下操作:

ruby script/console
。。。然后您处于开发模式,该模式可能具有“perform\u deliveries=false”或delivery\u方法的某些其他设置

相反,请在生产模式下运行控制台:

ruby script/console production
。。。或者将config/environments/development.rb更改为“perform_deliveries=true”

请注意environment.rb中的注释:

# Settings in config/environments/* take precedence over those specified here.

因此,如果在这两个位置都定义了某个内容,它将被特定于环境的设置覆盖

ActionMailer::Base.perform\u deliveries
在控制台中为您提供了什么?您的日志是否说明电子邮件已送达?