简体   繁体   English

Rails SMTPAuthenticationError 操作邮件程序

[英]Rails SMTPAuthenticationError Action Mailer

I've developed a Rails 3 app and I've recently added an action mailer for when a user signs up.我开发了一个 Rails 3 应用程序,并且最近添加了一个用于用户注册时的操作邮件程序。
Testing it locally and it sends an email perfectly, but when I move it to the server at test it for a new user signing up, I get the following error.在本地测试它并完美地发送 email,但是当我将它移动到服务器以测试新用户注册时,我收到以下错误。

I am running Nginx on the server with the original configurations, both local machine and server are running ubuntu 11.10我在原始配置的服务器上运行 Nginx,本地机器和服务器都在运行 ubuntu 11.10

Net::SMTPAuthenticationError in UsersController#create Net::SMTPAuthenticationError in UsersController#create
535-5.7.1 Username and Password not accepted. 535-5.7.1 不接受用户名和密码。
app/controllers/users_controller.rb:26:in 'create'应用程序/控制器/users_controller.rb:26:在“创建”

In users_controller.rb - create - Line 26 is UserMailer.welcome_email(@user).deliver在 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


In development.rb I have the following code:在 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@mydomain.co.uk',
    :password             => 'email_password',
    :authentication       => 'plain',
    :enable_starttls_auto => true  }

user_mailer.rb user_mailer.rb

class UserMailer < ActionMailer::Base
  default :from => "univeristy.sports@louisgriffiths.co.uk"

  def welcome_email(user)
    @user = user
    @url  = "http://www.mydomain:3000"
    mail(:to => user.email, :subject => "Welcome to University Sports")
  end
end

I had the exact same error and found that my application.yml file was overriding it so I deleted that and now it works fine!我遇到了完全相同的错误,发现我的 application.yml 文件覆盖了它,所以我删除了它,现在它可以正常工作了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM