I have a contact form and after submitting I am getting a Net::SMTPAuthenticationError 535-5.7.8 Username and Password not accepted
It's pointing to the create action in the contacts controller ContactMailer.new_contact(@contact).deliver
I have restarted the server. I tried https://accounts.google.com/DisplayUnlockCaptcha.
I am in development.
Contacts controller:
 def new       @contact = Contact.new     end      def create       @contact = Contact.new(params[:message])       if @contact.valid?         ContactMailer.new_contact(@contact).deliver         flash[:notice] = "Message sent! Thank you for contacting us."         redirect_to root_url       else         render :action => 'new'       end     end   end Development.rb:
  config.action_mailer.raise_delivery_errors = true   config.action_mailer.perform_deliveries = true   config.action_mailer.delivery_method = :smtp   config.action_mailer.smtp_settings = {     address:              'smtp.gmail.com',     port:                 587,     domain:               'gmail.com',     user_name:            '[email protected]',     password:             'password',     authentication:       'plain',     enable_starttls_auto: true  }    config.action_mailer.default_url_options = { :host => "localhost:3000" } If getting "Username and Password not accepted" 535 5.7. 8 error, but user name and password work logging onto email via web (with 2-factor authentication), you may need to enable "Access for less secure apps" (allow exceptions to 2-factor authentication) in your email settings.
I had the same problem. Now its working fine after doing below changes.
https://www.google.com/settings/security/lesssecureapps
You should change the "Access for less secure apps" to Enabled (it was enabled, I changed to disabled and than back to enabled). After a while I could send email.
First, You need to use a valid Gmail account with your credentials.
Second, In my app I don't use TLS auto, try without this line:
config.action_mailer.smtp_settings = {   address:              'smtp.gmail.com',   port:                 587,   domain:               'gmail.com',   user_name:            '[email protected]',   password:             'YOUR_PASSWORD',   authentication:       'plain'   # enable_starttls_auto: true   # ^ ^ remove this option ^ ^ } UPDATE: (See answer below for details) now you need to enable "less secure apps" on your Google Account
https://myaccount.google.com/lesssecureapps?pli=1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With