【发布时间】:2011-09-14 20:15:54
【问题描述】:
服务器指出电子邮件已发送到正确的地址,但我的收件箱中没有收到邮件。
我的 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
default :from => "my_user_name@gmail.com"
def registration_confirmation(user)
mail(:to => user.email, :subject => "Thanks for registering")
end
end
【问题讨论】:
-
您能否发布此邮件特定于模型和控制器的代码?
-
我认为 google 要求您使用 SSL/TLS。
-
@caley Woods: :enable_starttls_auto => true 表示使用 SSL/TLS!
-
@andre 谢谢我错过了那行。
标签: ruby-on-rails-3 actionmailer railscasts