我将environment.rb文件配置如下:
# Load the Rails application.
require File.expand_path('../application', __FILE__)
# Initialize the Rails application.
Rails.application.initialize!
rapp::Application.configure do
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: "gmail.com",
authentication: :login, # will send password Base64 encoded
user_name: "myadress",
password: "mypass",
enable_starttls_auto: true
}
end但是,当我试图生成这样的mailer类时:
rails generate mailer MailNotifier template1 template2 template3我发现了一个错误:
/home/usr/.../rapp/config/environment.rb:7:in `<top (required)>': undefined local variable or method `rapp' for main:Object (NameError)
from /home/usr/.rvm/gems/ruby-2.1.0/gems/railties-4.1.0/lib/rails/application.rb:264:in `require'
from /home/usr/.rvm/gems/ruby-2.1.0/gems/railties-4.1.0/lib/rails/application.rb:264:in `require_environment!'
from /home/usr/.rvm/gems/ruby-2.1.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:147:in `require_application_and_environment!'
from /home/usr/.rvm/gems/ruby-2.1.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:133:in `generate_or_destroy'
from /home/usr/.rvm/gems/ruby-2.1.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:51:in `generate'
from /home/usr/.rvm/gems/ruby-2.1.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from /home/usr/.rvm/gems/ruby-2.1.0/gems/railties-4.1.0/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'有人能帮忙解决这个问题吗?
发布于 2014-05-09 16:44:05
将action_mailer设置为:-
http://stackoverflow.com/questions/23300150/actionmailer-not-working-when-i-change-gmail-password/23300459#23300459从environment.rb文件中删除
rapp::Application.configure do
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: "gmail.com",
authentication: :login, # will send password Base64 encoded
user_name: "myadress",
password: "mypass",
enable_starttls_auto: true
}
end那就试试:-
rails generate mailer MailNotifier template1 template2 template3https://stackoverflow.com/questions/23569542
复制相似问题