我正在尝试使用Rails 4.0.1和Ruby 2.0.0向新注册的用户发送确认电子邮件。
我没有收到任何错误,但邮件没有发送。以下是相关代码:
配置/环境/ development.rb
...
config.action_mailer.smtp_settings = {
:authenication=>:plain,
:address=>"smpt.mailgun.org",
:port=>587,
:domain=>"sandboxf4f4c96ebc7b4eb1b6c7475ad4de048c.mailgun.org",
:user_name=>"postmaster@sandboxf4f4c96ebc7b4eb1b6c7475ad4de048c.mailgun.org",
:password=>"6j3c9l35tu33"
}
应用程序/模型/ user.rb
...
def create
@user=User.new(user_params)
if @user.save
ModelMailer.account_activation(@user).deliver
redirect_to lessons_url
else
render :new
end
end
寄件人/ model_mailer.rb
class ModelMailer < ActionMailer::Base
default from: "me@sandboxf4f4c96ebc7b4eb1b6c7475ad4de048c.mailgun.org"
def account_activation(user)
@user = user
mail to: "myemail@gmail.com", subject: "Account Activation"
end
end
任何帮助都将不胜感激。