Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ruby-gmail: Uncaught exception: 534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbtMk

I can manually login my account, but when i use ruby-gmail, it will raise err

this is my code

require 'gmail'

gmail = Gmail.new("[email protected]", "passwd")

gmail.deliver do
  to "[email protected]"
  subject "Having fun in Puerto Rico!"
  text_part do
    body "Text of plaintext message."
  end
  html_part do
    content_type 'text/html; charset=UTF-8'
    body "<p>Text of <em>html</em> message.</p>"
  end
  add_file __FILE__
end

this is my full output

Uncaught exception: 534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbtMk

    /home/roroco/.rbenv/versions/2.1.5/lib/ruby/2.1.0/net/smtp.rb:969:in `check_auth_response'
    /home/roroco/.rbenv/versions/2.1.5/lib/ruby/2.1.0/net/smtp.rb:740:in `auth_plain'
    /home/roroco/.rbenv/versions/2.1.5/lib/ruby/2.1.0/net/smtp.rb:732:in `authenticate'
    /home/roroco/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/ruby-gmail-0.3.1/lib/smtp_tls.rb:57:in `do_tls_start'
    /home/roroco/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/ruby-gmail-0.3.1/lib/smtp_tls.rb:18:in `start'
    /home/roroco/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/mail-2.6.1/lib/mail/network/delivery_methods/smtp.rb:112:in `deliver!'
    /home/roroco/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/mail-2.6.1/lib/mail/message.rb:248:in `deliver!'
    /home/roroco/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/ruby-gmail-0.3.1/lib/gmail.rb:107:in `deliver'
    /home/roroco/Dropbox/rbs/ro_plans/ex/ex.rb:5:in `<top (required)>'

update

solution: https://security.google.com/settings/u/1/security/apppasswords > generate new for mail > remember it > fill it in ruby-gmail passwd

like image 954
anyvoleki Avatar asked Dec 21 '14 05:12

anyvoleki


1 Answers

Gmail has some security features that have to be enabled/disabled 1 - Inside your gmail account go to Settings > Forwarding and POP/IMAP and enable the protocols(s) that you wish to use

2 - Enable access of less secure apps https://www.google.com/settings/security/lesssecureapps

like image 116
Vitor Avatar answered Oct 03 '22 19:10

Vitor