Created
July 12, 2017 01:54
-
-
Save mldoscar/831945304771d0b2ea668066feec09e5 to your computer and use it in GitHub Desktop.
ActionMailer fix for ZOHO MAIL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: '[email protected]' | |
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'], # [email protected] | |
:password => ENV['MAILER_PASS'], | |
:authentication => :plain, | |
:enable_starttls_auto => true | |
} | |
config.action_mailer.default_options = { | |
:from => ENV['MAILER_FROM_ADDR'] # [email protected] | |
} | |
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