Ruby on Railsチュートリアル第11章「アカウントの有効化」できなくて困っています。
チュートリアルに沿って、進めてきたのですがSendGridからメールが送られてこないエラーが発生しました。
Ruby
1 config.action_mailer.delivery_method = :smtp 2 config.action_mailer.raise_delivery_errors = true 3 config.action_mailer.perform_deliveries = true 4 config.action_mailer.default :charset => "utf-8" 5 host = 'localhost:3000' 6 config.action_mailer.default_url_options = { host:'localhost', port: '3000' } 7 ActionMailer::Base.smtp_settings = { 8 :address => 'smtp.sendgrid.net', 9 :port => '587', 10 :authentication => :plain, 11 :user_name => ENV['SENDGRID_USERNAME'], 12 :password => ENV['SENDGRID_PASSWORD'], 13 :domain => 'localhost:3000', 14 :enable_starttls_auto => true 15 }
上記を「development.rb」にて設定したはずなのですが、一向に動く気配がありません。。実際の登録画面でアカウント登録をすると、下記のエラーが発生してしまいます。
Net::SMTPFatalError in UsersController#create
550 Unauthenticated senders not allowed
Extracted source (around line #52):
Ruby
1・・・ 2 # 有効化用のメールを送信する 3 def send_activation_email 4 UserMailer.account_activation(self).deliver_now 5 end 6 7 private 8 9 # メールアドレスをすべて小文字にする 10 def downcase_email 11 self.email = email.downcase 12 end 13 14 # 有効化トークンとダイジェストを作成および代入する 15 def create_activation_digest 16 self.activation_token = User.new_token 17 self.activation_digest = User.digest(activation_token) 18 end 19end
下記にエラーがあるみたいです。。
(users_controller.rb)
Ruby
1・・・ 2 def create 3 @user = User.new(user_params) 4 if @user.save 5 @user.send_activation_email 6 flash[:info] = "Please check your email to activate your account." 7 redirect_to root_url 8 else 9 render 'new' 10 end 11 end 12・・・
(User.rb)
Ruby
1・・・ 2 # アカウントを有効にする 3 def activate 4 update_attribute(:activated, true) 5 update_attribute(:activated_at, Time.zone.now) 6 end 7 8 # 有効化用のメールを送信する 9 def send_activation_email 10 UserMailer.account_activation(self).deliver_now 11 end 12・・・
何度も申し訳ありませんが、お助けくださいませ。
どうぞよろしくお願いいたします。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/05/02 06:48
2017/05/02 06:52
2017/05/02 07:05