1
我開發了一個Rails 3應用程序,並且最近添加了一個用戶註冊時的動作郵件。
在本地進行測試,它完美地發送了一封電子郵件,但是當我將它移動到服務器以測試新用戶時,我收到以下錯誤消息。
我與原來配置的服務器上運行Nginx的,無論是本地機和服務器正在運行Ubuntu 11.10
Rails SMTPAuthenticationError Action Mailer
的Net :: SMTPAuthenticationError在UsersController#創建
535-5.7.1用戶名和密碼不接受。
應用程序/控制器/ users_controller.rb:26:在 '創建'
在users_controller.rb - 創建 - 26行是UserMailer.welcome_email(@user).deliver
def create
@user = User.new(params[:user])
if @user.save
sign_in @user
flash[:success] = "Welcome to University Sports!"
redirect_to @user
UserMailer.welcome_email(@user).deliver
else
@title = "Sign up"
render 'new'
end
end
在development.rb我有以下代碼:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => 'smtp.gmail.com',
:port => 587,
:domain => 'www.mydomain.co.uk',
:user_name => '[email protected]',
:password => 'email_password',
:authentication => 'plain',
:enable_starttls_auto => true }
user_mailer.rb
class UserMailer < ActionMailer::Base
default :from => "[email protected]"
def welcome_email(user)
@user = user
@url = "http://www.mydomain:3000"
mail(:to => user.email, :subject => "Welcome to University Sports")
end
end
是您的服務器設置爲在生產模式下運行?如果是這樣,您需要將您在development.rb中完成的設置添加到production.rb – 2012-04-10 00:21:48
我也嘗試過,但我沒有任何運氣。 – Spoons 2012-04-10 00:28:13