Skip to content

Instantly share code, notes, and snippets.

@mldoscar
Created July 12, 2017 01:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mldoscar/831945304771d0b2ea668066feec09e5 to your computer and use it in GitHub Desktop.
Save mldoscar/831945304771d0b2ea668066feec09e5 to your computer and use it in GitHub Desktop.
ActionMailer fix for ZOHO MAIL
Same thing happened to me, about the error EOFError, Completed 500 Internal Server Error.
The weird thing was that devise gem, was working sweet. But my custom mailers not. So I wondered, WHY THE HELL DEVISE WAS WORKING AND THE REST NOT?
The answer is that in devise configuration uses ActionMailer::Base as mailer sender. But my custom mailers were using ApplicationMailer class, a derivate of ActionMailer::Base, so I went to take a look at '/app/mailers/application_mailer.rb' to see what's wrong… and i've found that ApplicationMailer class has a default 'from' value which throws an error because obviously that email does not exist. Now by default ActionMailer comes like this:
class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com'
layout 'mailer'
end
So what I did was that I removed the 'default from….' line and I just kept this:
class ApplicationMailer < ActionMailer::Base
layout 'mailer'
end
Now ApplicationMailer class and all its children classes will use the default values you set in your mailer initializer wherever it is, mine is at '/config/initializers/mailer.rb':
Rails.application.configure do
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => 'smtp.zoho.com',
:port => '587',
:domain => 'mydomain.com',
:user_name => ENV['MAILER_USER'], # mailer@mydomail.com
:password => ENV['MAILER_PASS'],
:authentication => :plain,
:enable_starttls_auto => true
}
config.action_mailer.default_options = {
:from => ENV['MAILER_FROM_ADDR'] # support@mydomain.com
}
end
Hope It helps for someone. That worked for me
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment