title: 535-5.7.8 Username and Password not accepted error
body: <p>I am getting this error while using action mailer to send mail via my gmail account.</p>
  
  <blockquote>
    <p>Net::SMTPAuthenticationError in SweepstakesController#show
    535-5.7.8 Username and Password not accepted.<br>
     Learn more at:
           ParticipantMailer.winner_confirmation(@result).deliver_now!</p>
  </blockquote>
  
  <p>I have double checked my email and password,i have restarted my server,also i have gone through all previous questions related to this error here and implemented every answer but to no avail.
  My development.rb file is:</p>
  
  <pre><code>config.action_mailer.default_url_options = { host: 'localhost', port:        3000}
  ActionMailer::Base.delivery_method= :smtp
  ActionMailer::Base.smtp_settings = {
    :address =&gt;"smtp.gmail.com",
    :port =&gt; 587,
    :domain =&gt; "gmail.com",
    :user_name =&gt; "my_email@gmail.com",
    :password =&gt; "my_password",
    :authentication =&gt; 'plain',
    :openssl_verify_mode =&gt; 'none' 
  }
  </code></pre>
  
  <p>Logic in controller:</p>
  
  <pre><code>def show
    @sweepstake = Sweepstake.find(params[:id])
    @participant = Participant.where(:sweepstake_id =&gt; @sweepstake.id )
    b = @sweepstake.winner_count
    @result = Array.new 
    b.times do 
      @result &lt;&lt; @participant[rand(@participant.count)]
    end
    ParticipantMailer.winner_confirmation(@result).deliver_now!
  end
  </code></pre>
  
  <p>participant_mailer.rb file:</p>
  
  <pre><code>class ParticipantMailer &lt; ApplicationMailer
    default from: 'rajesh010794@gmail.com'
  
    def winner_confirmation(result)
      @result = result
      @url  = 'http://example.com/login'
  
      Rails.logger.info(@result.inspect)
      @result.each do |i|
        mail(to: i.participant_email, subject: 'Congratulation')
      end
    end
  end
  </code></pre>