在Rails 3.2中使用gmail或SendGrid发送邮件认证错误 [英] mailer authentication error in Rails 3.2 with gmail or SendGrid

查看:160
本文介绍了在Rails 3.2中使用gmail或SendGrid发送邮件认证错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从一个非常简单的Rails 3.2应用程序设置邮件。试过Gmail,试过SendGrid。

  UsersController中的Net :: SMTPAuthenticationError#create 
530-5.5.1需要身份验证

这是我的环境部分/ development.rb

 #如果邮件程序无法发送
,请注意config.action_mailer.raise_delivery_errors = true

#将邮件传递更改为:smtp,:sendmail,:文件,:test
config.action_mailer.delivery_method =:smtp
config.action_mailer.smtp_settings = {
地址:smtp.gmail.com,
端口:587,
domain:signaldesign.net,
authentication:plain,
enable_starttls_auto:true,
user_name:ENV [gmailusername],
密码:ENV [ gmailpassword]
}

这里是我的users_controller

  def创建
@user = User.new(params [:user])
if @ user.save
UserMailer.signup_confirmation (@user).deliver
sign_in @user
fl灰[:success] =欢迎!
redirect_to @user
else
渲染'新'
结束
结束

我很难过。我在网上找到的所有建议都没有改变。

解决方案

我想通了。

我更改了我的smtp_settings用户名和密码:

 user_name:ENV [gmailusername],
密码:ENV [gmailpassword]

  user_name:gmailusername,
密码:gmailpassword


I'm trying to set up mailing from a very simple Rails 3.2 app. Tried Gmail, tried SendGrid. Getting same error.

Net::SMTPAuthenticationError in UsersController#create
530-5.5.1 Authentication Required

Here's my section of environments/development.rb

# Care if the mailer can't send
config.action_mailer.raise_delivery_errors = true

# Change mail delivery to either :smtp, :sendmail, :file, :test
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  address: "smtp.gmail.com",
  port: 587,
  domain: "signaldesign.net",
  authentication: "plain",
  enable_starttls_auto: true,
  user_name: ENV["gmailusername"],
  password: ENV["gmailpassword"]
}

Here's my users_controller

def create
  @user = User.new(params[:user])
  if @user.save
    UserMailer.signup_confirmation(@user).deliver
    sign_in @user
    flash[:success] = "Welcome!"
    redirect_to @user
  else
    render 'new'
  end
end

I'm stumped. None of the suggestions I've found online are making a difference.

解决方案

I figured it out. I finally resorted to just deleting things and trying again.

I changed my smtp_settings username and password from:

user_name: ENV["gmailusername"],
password: ENV["gmailpassword"]

to

user_name: "gmailusername",
password: "gmailpassword"

这篇关于在Rails 3.2中使用gmail或SendGrid发送邮件认证错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆