服务器指出电子邮件已发送到正确的地址,但我没有在收件箱中收到邮件。
我的 Setup_mail.rb 文件
ActionMailer::Base.smtp_settings ={
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:user_name => "my_user_name@gmail.com",
:password => "my_password",
:authentication => "Plain",
:enable_starttls_auto => true
}
我的development.rb
文件是:
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true #default value
config.action_mailer.delivery_method = :smtp #default value
我的test.rb
文件是:
config.action_mailer.delivery_method = :smtp
我尝试了多种变体并且迷路了。我在 Windows 7 机器上运行。我正在运行 Ruby 1.8.7 和 Rails 3.0.7
任何人都可以帮忙吗?
这是我的创建方法:
def create
@user = User.new(params[:user])
if @user.save
UserMailer.registration_confirmation(@user).deliver
sign_in @user
redirect_to @user, :flash => { :success => "Welcome to the Sample App!" }
else
@title = "Sign up"
render 'new'
end
end
我的 user_mailer.rb 类 UserMailer < ActionMailer::Base
default :from => "my_user_name@gmail.com"
def registration_confirmation(user)
mail(:to => user.email, :subject => "Thanks for registering")
end
end