We encountered an issue recently with Devise’s password reset emails. The sender address on the emails appeared as “sender@debian” rather than “sender@ourdomain.com”, despite the fact that we had configured Devise to use a specific address:

# config/initializers/devise.rb
Devise.setup do |config|
  config.mailer_sender = "Sender Name <sender@ourdomain.com>"

Interestingly, we did not have this issue with any other emails sent by the application, only the ones generated by Devise.

The server running this app is a Debian 6 (“squeeze”) box, running Sendmail.

The problem was a setting at the bottom of the Sendmail configuration file (/etc/mail/sendmail.mc).

The final lines of this file, before modification, were:

dnl # Masquerading options

This is the source of the “@debian” domain that was being used instead of the one we set in the application. For a simple fix, we just changed the MASQUERADE_AS setting to match the domain we wished to send from:

dnl # Masquerading options

With that, the Devise mails finally matched our application’s domain.