Rails 4 Net :: SMTPAuthenticationError: 535 # 5.7.0 Authentication Error

I am creating an email list for a student organization at my university. The organization has about 6,000 members, and to avoid costs, I got permission to use the school's email servers, and they created an account for me.

I checked the account using my email client and everything works fine, but when I try to send through the Rails 4 application, I get an error message:

 Net::SMTPAuthenticationError: 535 #5.7.0 Authentication failed 

I configured it like this:

application.rb

 config.action_mailer.smtp_settings = { :address => "smtp.school.edu", :port => 25, :enable_starttls_auto => true, :user_name => " account@school.edu ", :password => "mypassword", :authentication => 'login', :domain => 'http://myapp.herokuapp.com/' } 

Again, the credentials are correct, I tested them through my mail client and also sat down with the server administrator to make sure everything looks right in my configuration to the port and credentials.

I was told that the smtp server is "wide open to the public" and nothing blocks the connection, and we checked their logs and they did not even see an attempt to connect from my application.

Does anyone know what is going wrong here? Is there some kind of setting that I don't know about that can be turned off?

+6
source share
5 answers

Try adding openssl_verify_mode => 'none' to your mail program settings:

 config.action_mailer.smtp_settings = { :address => "smtp.school.edu", :port => 25, :enable_starttls_auto => true, :user_name => " account@school.edu ", :password => "mypassword", :authentication => 'login', :domain => 'http://myapp.herokuapp.com/', :openssl_verify_mode => 'none' } 

Of course, we use Rails 3, but it worked for me. The problem for us was that our certificates are self-signed, and the use of Rails libraries is considered a problem. Here is an article that talks about options.

+6
source

Should ": domain" point to "school.edu" instead of "herokuapp.com"? I know when you install smtp for gmail using the action_mailer settings, you have something like:

 config.action_mailer.smtp_settings = { :address => 'smtp.gmail.com', :port => 587, :domain => 'gmail.com', :user_name => ' example@gmail.com ', :password => 'example_password', :authentication => 'login', :enable_starttls_auto => true } 
+1
source

If the domain contains "http: //"?

+1
source

Create the setup_mail.rb file in the config/initializers/ folder and put the code: -

 ActionMailer::Base.delivery_method = :smtp ActionMailer::Base.perform_deliveries = true ActionMailer::Base.smtp_settings = { :address => "smtp.school.edu", :domain => 'myapp.herokuapp.com', :port => 25, :user_name => " account@school.edu ", :password => "mypassword", :authentication => :plain, :enable_starttls_auto => true } ActionMailer::Base.default_url_options[:host] = "myapp.herokuapp.com" 
+1
source

My problem was solved using the following steps.

 config.action_mailer.default :charset => "utf-8" config.action_mailer.perform_deliveries = true config.action_mailer.raise_delivery_errors = true config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { address: 'smtp.gmail.com', port: 587, domain: 'mysite.com', user_name: myemail@gmail.com , password: mypassword, authentication: 'plain', enable_starttls_auto: true } 

Because Google will try to block your entry if you have disabled access for less secure applications in your account settings. Therefore, follow this link and Enable for less secure applications.

0
source

Source: https://habr.com/ru/post/975008/


All Articles