Postfix is widely used Mail Transfer Agent (MTA) server, which provides to send, receive and forward emails over network. This tutorial will help you to configure your Postfix server to forward emails.
Install Postfix MTA
We are assuming that you already have postfix installed and configured on your system. Or you can use following commands to install Postfix on Linux box according to your operating system.
On Debian Based Systems
$ sudo apt-get update $ sudo apt-get install postfix
On RHEL Based Systems
# yum install postfix
On OpenSUSE Systems
# zypper in postfix
After installation make sure Postfix is running on your system. Default postfix used standard port 25. Use the following commands to check that your system is listening on port 25 or not.
# netstat -tulpn | grep 25 tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 4398/master tcp6 0 0 :::25 :::* LISTEN 4398/master
Configure Email Forwarding in Postfix
Let’s start with email forwarding configuration in Postfix configuration file (/etc/postfix/main.cf). Edit this file and add/edit the following configurations. Change example.com and example.net domain names with your domain name
virtual_alias_domains = example.com example.net virtual_alias_maps = hash:/etc/postfix/virtual
After making any changes in configuration files make sure to restart Postfix service.
Email Forwarding Examples
/etc/postfix/virtual is the file where we will add email forwarding rules. Let’s starts begin with the email forwarding rules.
1 – Forward all emails sent to [email protected] and [email protected] to [email protected]
[email protected] [email protected] [email protected] [email protected]
2 – Forward [email protected] emails to [email protected] and [email protected]
[email protected] [email protected] [email protected]
3 – Forward any email sent to @example.com domain to [email protected] Also forward any email sent to @example.net domain to [email protected] as well as [email protected]
@example.com [email protected] @example.net [email protected] [email protected]
Verify Setup
Let’s verify all settings by sending emails to @example.com and @example.net domain email accounts.
3 Comments
Thanks this works well
BUT…
When make forwarder to another email via gmail relayhost, it does not show the name of the email from the original sender, it shows the name of my host configured in google
example:
relayhost = [smtp.gmail.com]:587
From mail sender([email protected]) To destiny([email protected])
forwaring another mail ([email protected])
When arrive el mail to [email protected] through forwarding
It does not show the mail of the sender [email protected]
Show the sender’s mail using to do the relayhost example [email protected]
Please helpe
hi rahul
i have stuck in postfix
i have an private client ( 10.0.21.16 ) and Non -DMZ server ( 10.92.101.4) and DMZ server ( 10.92.103.1)
first i relayed my 10.0.21.16 mails to NON- DMZ
from Non -DMZ i have routed to DMZ
Now from DMZ i want to send (relay or route) to public domains ?
Note : i have bought public domain for DMZ server , my both client and Non – DMZ server have local domain which is using by inserting local domain in /etc/hosts
In order for this to work, after the creation of file /etc/postfix/virtual with the forwarding rules and before reloading the postfix service with postix reload, the following should be executed: postmap /etc/postfix/virtual.