howto:how_to_configure_nethserver_for_mail_configuration_with_office365_multiple_mailaccounts

Version / Revision: V1.0 / R1
For: Nethserver 6.7

Skill: Intermediate Users
Published: 2016-02-04
Review: 2016-00-00

Contact: Nethserver community forum, Davidep, Linux4All

Description

Authenticate separately each email address you want to send from. After implementing you will have a 1:1 mapping between the sending address “From:” and the auth credentials. You need this for example for Office 365 or if you use multiple email accounts from hosting services like google, gmx, yahoo, hotmail, etc.

I have running the config in my productive environment nevertheless be careful!
!!! Just do that if you know what you are doing !!!
All config has to be implemented at the command line.

Perhaps at a given time it will be implemented to the Web UI.

Postfix Main Configuration

First we have to do some enhancements to the postfix configuration.

Login to your nethserver via ssh or console.

Become root

su -

Edit the main.cf in templates-custom with an editor, for example vi

vi /etc/e-smith/templates-custom/etc/postfix/main.cf/90smarthosts_accounts

Press i for insert and add the following configuration

# 
# 90smarthosts_accounts (template-custom) 
# /etc/e-smith/templates-custom/etc/postfix/main.cf/90smarthosts_accounts 
# 
smtp_sender_dependent_authentication = yes 
sender_dependent_relayhost_maps = hash:/etc/postfix/relaymaps 
smtp_sasl_auth_enable = yes 
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd  
smtp_tls_policy_maps = hash:/etc/postfix/tls_policy
# Some providers only authentication via plain text
smtp_sasl_security_options = noanonymous 

Press :x to save the file and exit the editor

Edit the postfix_postmap in templates-custom with an editor, for example vi

vi /etc/e-smith/templates-custom/postfix/postmap/40smarthosts_accounts 

Press i for insert and add the following configuration

{ 
   # 
   # 40smarthosts_accounts (custom templates) 
   # /etc/e-smith/templates-custom/postfix/postmap/40smarthosts_accounts 
   # 
   push @postmapList, qw(relaymaps); 
   '';
}

Press :x to save the file and exit the editor

Postfix Personal Configuration

Edit the relaymaps in templates-custom with an editor, for example vi

vi /etc/e-smith/templates-custom/etc/postfix/relaymaps/90smarthosts_accounts 

Press i for insert and change the configuration to your needs

You have to add every email address also if there are multiple addresses for one email provider!
The :587 is for TLS encryption, sometimes you have to use :465 please check documentation at your email provider.

#
# 90smarthosts_accounts
# /etc/e-smith/templates-custom/etc/postfix/relaymaps/90smarthosts_accounts
#
# This lines are examples: replace with your personal data
#
first.user@{$DomainName}   smtp.gmail.com:587
heinz@me.com               smtp.mail.me.com:587
sam@web.de                 smtp.web.de:587
sarah1971@web.de           smtp.web.de:587       

Press :x to save the file and exit the editor

Edit the tls_policy in templates-custom with an editor, for example vi

vi /etc/e-smith/templates-custom/etc/postfix/tls_policy/90smarthosts_accounts 

Press i for insert and change the configuration to your needs.

Here you have to specify each domain you will sent emails from. The encrypt stands for encryption via TLS.
You need here all domains which were specified in relaymaps!

#
# 90accounts_smarthosts (template-custom)
# /etc/e-smith/templates-custom/etc/postfix/tls_policy/90smarthosts_accounts
#
# This lines are examples: replace with your personal data
#
smtp.mail.me.com:587 encrypt
smtp.web.de:587 encrypt

Press :x to save the file and exit the editor

Edit the sasl_passwd in templates-custom with an editor, for example vi

vi /etc/e-smith/templates-custom/etc/postfix/sasl_passwd/90smarthosts_accounts 

Press i for insert and change the configuration to your needs.

Here you have to specify all credentials for the mail addresses you will sent emails from. The email addresses should be matching the ones you defined in relaymaps above. The username can differ on each provider, sometimes you have a customer number or need the whole email address. If you are unsure please look at the providers documentation

#
# 90smarthosts_accounts (custom-template)
# /etc/e-smith/templates-custom/etc/postfix/sasl_passwd/90smarthosts_accounts
#
# This line is an example: replace it with actual data
#
first.user@{$DomainName}	isp_username:isp_password
heinz@me.com                    heinz@me.com:secret!
sam@web.de                      sam:mypassword
sarah1971@web.de                sarah1971:123pass

Press :x to save the file and exit the editor

To be more secure, lets change the rights for this file to read by root only. Please enter the following:

chmod 640 /etc/e-smith/templates-custom/etc/postfix/sasl_passwd/90smarthosts_accounts

Go Live!

After you have all done finish your configuration by the following two commands

expand-template /etc/postfix/relaymaps
signal-event nethserver-mail-common-save

If you have all done right you should have a working configuration :-)
Please check the logfile for errors.

\\

You can do this via the Web Frontend -> Logviewer -> /var/log/maillog
Click on Follow to get the latest messages

If you need any further help, do not hesitate to ask at the community forum!
You are welcome!

Hopefully I could help you with that howto.

Linux4All

  • howto/how_to_configure_nethserver_for_mail_configuration_with_office365_multiple_mailaccounts.txt
  • Last modified: 2019/08/04 12:35
  • by linux4all