Я пытаюсь настроить электронную почту в своем приложении rails, и я получаю сообщение об ошибке «Net :: SMTPAuthenticationError (ошибка 535 аутентификации: неверное имя пользователя/пароль ) «когда я запускаю действие почты в рабочей среде.Rails: Net :: SMTPAuthenticationError (535 Ошибка аутентификации: неверное имя пользователя/пароль)
Контроллер:
class FeedbacksController < InheritedResources::Base
def create
@feedback = Feedback.new(feedback_params)
@user = current_user
respond_to do |format|
if @feedback.save
ExampleMailer.sample_email(@user).deliver
format.html { redirect_to @feedback, notice: 'feedback was successfully created.' }
format.json { render :show, status: :created, location: @user }
else
format.html { render :new }
end
end
end
end
конфигурации/среда/production.rb:
config.action_mailer.default_url_options = { :host => 'myurl.com:4321' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "myurl.com:4321",
:user_name => "[email protected]",
:password => "mypassword",
:authentication => "plain",
:enable_starttls_auto => true
}
example_mailer.rb:
class ExampleMailer < ActionMailer::Base
default from: "[email protected]
def sample_email(user)
@user = user
mail(to: @user.email, subject: 'sample email')
end
end