Hi, I lost some hours to figure out, what the problems were to make sending via smtp working.
Here is a list you should check if something does not work:
- To enable raising exceptions during email sending make sure you add the following line into environment.rb:
config.action_mailer.raise_delivery_errors = true
Or put it into the test.rb or development.rb which will overwrite the settings specified in environment.rb - Enable real email sending in test environment is possible in test.rb via
config.action_mailer.delivery_method = :smtp
instead of
config.action_mailer.delivery_method = :test
or directly use the following line in the test code
ActionMailer::Base.delivery_method = :smtp - if you get for your yahoo accout sth. like: EOFError: end of file reached.
Or for your gmx account:
Net::SMTPFatalError: 550 5.1.7 This server does not accept an empty envelope from ( http://portal.gmx.net/serverrules ) {mp038}
You should check that the ‘from’ property is really only the email not anything else! (See the next point) - If you use the restful_authentication plugin you can use the following code in user_mailer.rb:
def setup_email(user,subj=nil)
recipients “#{user.email}”
from “#{FROM_EMAIL}”
subject “[#{SITE}] #{subj}”
sent_on Time.now
body :user => user
endIn environment.rb directly after the rails gem version constant add:
SITE = ‘http://domain-you-like.de’
FROM_EMAIL = ‘fromemail@gmx.de’And in the ‘Rails::Initializer.run do |config|’ block do:
config.action_mailer.default_charset = “utf-8”
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => “mail.gmx.net” ,
:port => 25,
:domain => “localhost” ,
:authentication => :login,
:user_name => FROM_EMAIL ,
:password => “donotshare”
}
Thanks! That probably saved me a couple of hours of troubleshooting…