簡體   English   中英

Ruby on Rails中的Mailer

[英]Mailer in Ruby on Rails

我正在將ROR3應用程序遷移到ROR4。 我對此很陌生,我正在與遷移一起學習。 我在第一步中陷入了自我錯誤

Net::SMTPAuthenticationError in ClientsController#create
534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbtq6

這是我在development.rb中的配置。

config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }

  ActionMailer::Base.smtp_settings = {
          :address              => "smtp.gmail.com",
          :port                 => 587,
          :domain               => "gmail.com",
          :user_name            => Rails.application.secrets.email_address,
          :password             => Rails.application.secrets.email_password,
          :authentication       => "plain",
          :enable_starttls_auto => true }

我得到錯誤的地方是

@ client.save。

 Apartment::Tenant.create(@client.subdomain)
      Apartment::Tenant.switch(@client.subdomain)
      @client.save
      redirect_to new_user_session_url(subdomain: @client.subdomain)
    else
      render action: 'new'

任何人都可以幫助從事ROR的人嗎?

我也遇到了同樣的問題,請務必查看您的gmail帳戶安全設置,並"Access for less secure apps" from www.google.com/settings/security."啟用"Access for less secure apps" from www.google.com/settings/security."

嘗試這個

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
     :address => "smtp.gmail.com",
     :port => 587,
     :user_name => "your mail",
     :password => "your password",
     :authentication => :plain,
     :enable_starttls_auto => true
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM