Skip to content

Latest commit

 

History

History
65 lines (50 loc) · 1.75 KB

config-examples.md

File metadata and controls

65 lines (50 loc) · 1.75 KB

Loging

Create a log file con be done two ways.

#run the command
postconf maillog_file= /var/log/postfix.log

or it can be done by adding a line to mail.cf

echo "postconf maillog_file= /var/log/postfix.log"

Rewrite or forward emails

re-write can be handled via a /etc/postfix/generic file.

In the postfix/main.cf add the following

#/etc/postfix/main.cf
smtp_generic_maps = hash:/etc/postfix/generic

Then create a /etc/postfix/generic file as below and add additional users if needed.

root@localdomain myaccount@myoffice356domain.com
@localdomain myaccount@myoffice356domain.com
root@myserver  myaccount@myoffice356domain.com
userA@myserver myaccount@myoffice356domain.com

After creating this file you need to update thew postfix lookup table management by using the postmap command

# after creating or changing the generic file run postmap
postmap /etc/postfix/generic

# restart postfix
systemctl restart postfix

Dont forget to postmap an restart after changing the files

Domain rewriting with canonical maps

In some cases you want to rewrite all email for a specific domain to another domains. For example all incoming email for example.org should be rewritten to example.com. Postfix uses canonical maps to rewrite domains or mail addresses. Insert the following line to the /etc/postfix/main.cf:

# /etc/postfix/main.cf
canonical_maps = hash:/etc/postfix/canonical

create a new file /etc/postfix/cononical and define in this file the domain rewrites

@example.org   @example.com
# after creating or changing the generic file run postmap
postmap /etc/postfix/canonical

# restart postfix
systemctl restart postfix

Dont forget to postmap an restart after changing the files