Sending emails fails with 500 ArgumentError: Missing host to link to

@maikel and I tracked down a problem with the UK mail setup and would like to share the fix here.

We found that the UK server had a mail method configured, but it was set for the staging environment, when the server was running in production. The consequence of that was that Spree ignored the mail method, and didn’t set some configuration variables. This resulted in a 500 error when attempting to send emails: ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true.

We resolved this by changing the environment of the mail method to production, and this resulted in mails sending successfully.

We would like this problem to be more obvious to fix, so we’re planning to add a warning to the dashboard and the configuration to indicate when this is the case.

1 Like

We also found one other error in the process. We were seeing EOFError: end of file reached. When we changed the mail method port from 465 to 587 as recommended by mandrill, this solved the problem.