Setup relayhost

Attention

Check out the lightweight on-premises email archiving software developed by iRedMail team: Spider Email Archiver.

Relay host is a server which can accept your email and sent it out to the final destination for you.

Global relay host

To setup a global relay host in iRedMail, please append below settings in Postfix config file /etc/postfix/main.cf (Linux/OpenBSD) or /usr/local/etc/postfix/main.cf (FreeBSD):

relayhost = [relay_server]:25
smtp_sasl_password_maps = hash:/etc/postfix/sasl_password
smtp_sasl_auth_enable = yes
smtp_sasl_mechanism_filter = login
smtp_sasl_security_options = noanonymous

Note

Then write the username and password in /etc/postfix/sasl_password:

relay.server user:password

Run postmap and restart Postfix service:

postmap hash:/etc/postfix/sasl_password
service postfix restart

Sender dependent relay host

Attention

Sender dependent relay host is available in iRedMail-0.9.5 or later releases.

If your sender dependent relay host requires SMTP Authentication

If your sender dependent relay host requires SMTP Authentication, please add one more Postfix parameter in /etc/postfix/main.cf (Linux/OpenBSD) or /usr/local/etc/postfix/main.cf (FreeBSD):

smtp_sender_dependent_authentication = yes

Then add smtp username and password in file /etc/postfix/sasl_password like below:

user@domain.com smtp_user:smtp_password

Don't forget to run postmap hash:/etc/postfix/sasl_password after modified this file.

Manage with iRedAdmin-Pro

Since iRedAdmin-Pro-SQL-2.4.0 or iRedAdmin-Pro-LDAp-2.6.0, it's able to manage per-domain or per-user sender dependent relay host in domain or user profile page, under tab Relay. Screenshot attached.

Manage with command line tools

MySQL, MariaDB, PostgreSQL

For SQL backends, you can manage sender dependent relay host in SQL table mailbox.sender_relayhost. We use MySQL for example below.

sql> USE vmail;
sql> INSERT INTO sender_relayhost (account, relayhost) VALUES ('@domain.com', '[mail.gmail.com]:25');
sql> USE vmail;
sql> INSERT INTO sender_relayhost (account, relayhost) VALUES ('user@domain.com', '[mail.gmail.com]:25');

OpenLDAP

For OpenLDAP backend:

Sample LDIF data:

dn: domainName=mydomain.com,o=domains,dc=example,dc=com
senderRelayHost: [mail.gmail.com]:25
...
dn: mail=user@mydomain.com,ou=Users,domainName=mydomain.com,o=domains,dc=example,dc=com
senderRelayHost: [mail.gmail.com]:25
...

Screenshot of iRedAdmin-Pro

See Also