1

Topic: SMTP configuration for sending rails-devise emails

==== Required information ====
- iRedMail version (check /etc/iredmail-release):
- Linux/BSD distribution name and version:
- Store mail accounts in which backend (LDAP/MySQL/PGSQL):
- Web server (Apache or Nginx):
- Manage mail accounts with iRedAdmin-Pro?
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====First at all, thanks for providing freely an efficient email server.
We're using iRedMail in 4 email servers (8 domains) for our own email accounts.
We develop web apps (mx.coopeu.com) based on RoR.
We would like to know what is the iRedMail configuration for sending, via rails and devise gem, the password reminds, emails confirmations,... .
After Googling, we're posting here because we only find smt gmail config, please find below, of the authentication based on gem devise: https://github.com/plataformatec/devise.
Thanks in advance,
Ferran

==== DEVISE config/environments/development.rb ====
Our config: config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
SMTP GMAIL CONFIG: 
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "mail.google.com",
:user_name => "my@gmail.com",
:password => "mypassword",
:authentication => :plain,
:enable_starttls_auto => true
}
==== Required information ====
- 0.9.7 MARIADB edition.
- Debian GNU/Linux 9 (stretch) in a fresh OVZ-6GB
- Mysql/MariaDB w/ adminer
- Apache/2.4.25 (Debian)
- PHP 7.0.19-1
- Ruby 2.5.0, Rails 5.1.5 and Phusion Passenger 5.2.1
- No errors: /var/log/iredapd/iredapd.log
=============================

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: SMTP configuration for sending rails-devise emails

coopeu wrote:

config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "mail.google.com",
:user_name => "my@gmail.com",
:password => "mypassword",
:authentication => :plain,
:enable_starttls_auto => true
}

This should work for iRedMail out of box (with correct server address, username + password).
FYI: https://docs.iredmail.org/#mua

3

Re: SMTP configuration for sending rails-devise emails

Editing DEVISE config/environments/development.rb

config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.smtp_settings = {
:address => "mx.coopeu.com",
:port => 587,
:domain => "mx.cooopeu.com",
:user_name => "coopeu@coopeu.com",
:password => "password",
:authentication => :plain,
:enable_starttls_auto => true
}

Also raising error:

Net::SMTPFatalError in ConfirmationsController#create

554 5.7.1 <coopeu@coopeu.com>: Recipient address rejected: Sender is not same as SMTP authenticate username

4

Re: SMTP configuration for sending rails-devise emails

coopeu wrote:

Sender is not same as SMTP authenticate username

It means you use user "coopeu@coopeu.com" for SMTP authentication, but specify user "someone-else@somedomain.com" as the sender address.

If you need to allow the sender address mismatch for this smtp user, you can add one setting in /opt/iredapd/settings.py to allow it, like below:

ALLOWED_LOGIN_MISMATCH_SENDERS = [coopeu@coopeu.com']

Restarting iredapd after modified "settings.py".

5

Re: SMTP configuration for sending rails-devise emails

1) Changing to :user_name => "consen@consen.org" at config/environments/development.rb is raising error
    def check_auth_response(res)
      unless res.success?
        raise SMTPAuthenticationError, res.message
      end
    end
2) Adding ALLOWED_LOGIN_MISMATCH_SENDERS = [coopeu@coopeu.com'] at /opt/iredapd/settings.py raising iredapd service restart error
Active: failed (Result: exit-code) since Tue 2018-03-13 17:26:30 UTC; 22s a
Process: 12477 ExecStart=/usr/bin/python /opt/iredapd/iredapd.py (code=exite
mx systemd[1]: Failed to start iRedAPD (A simple posfix policy
After commenting this added line, iredapd service restart normally

6

Re: SMTP configuration for sending rails-devise emails

coopeu wrote:

1) Changing to :user_name => "consen@consen.org" at config/environments/development.rb is raising error
    def check_auth_response(res)
      unless res.success?
        raise SMTPAuthenticationError, res.message
      end
    end

Seems wrong username/password? It says "SMTPAuthenticationError".

coopeu wrote:

2) Adding ALLOWED_LOGIN_MISMATCH_SENDERS = [coopeu@coopeu.com'] at /opt/iredapd/settings.py raising iredapd service restart error

My mistake, missed one single quote. It should be:

ALLOWED_LOGIN_MISMATCH_SENDERS = ['coopeu@coopeu.com']

7

Re: SMTP configuration for sending rails-devise emails

Now is working fine.
user email iRedMail equal to user email of rails config environment
Thank you!
Enjoy of my coffee!