Thursday, March 4, 2010

9. Postfix SmartHost and NullClient

    SmartHost forwards all the mails that are not destined to the same server. Ideally this feature is used to forward mails to the SmartHost Mail server which can masquerade and relay mails to outer world.
Mail Flow example:
Local Server -> SmartHost Server -> Outer World
    In Local server we defines the SmartHost server. So all the mails that are not destined to the Local server will be forwarded to SmartHost Server. Then SmartHost server forwards the msgs to the outer world.

Defining SmartHost
Initially check that what domains the postfix will accept the mails for.
# postconf |grep mydestination
    The output shows the list of the domains that postfix accepts mails for. After defining the SmartHost postfix will forward all the mails to the SmartHost server which are not destined to $mydestination.
# vim /etc/postfix/
relayhost =
    In this scenario postfix forwards all the mails that are not destined local to
Note: In this case the postfix will perform DNS MX record query to the domain Adding square brackets "[]" will skip the MX record query and delivers the msgs directly.
eg: relay_host = []
# postconf |grep relayhost
# postfix reload
Verify the configuration and reload the postfix service
    Test the configuration by sending mails to outside using this Local Server.Examine the Logs in the Local server as well as in the SmartHost server.

    NullClient forwards all the mails including locally generated to the defined server. NullClient never receives any mails.
Mail Flow Example:
internet -> Mail Server exposed Internet -> Internel Mail Server
    From any internet Box the Mail server Exposed to Internet will accept the mails and Using the NullCLient configuration all the mails will be forwarded to Internal Mail Server.

Configuring the NullClient
In the above mail flow diagram the configuration come at the Mail server exposed to Internet
# vim /etc/postfix/
mydestination =
local_transport = error:Local Mailing is Disabled
relayhost =
mydestination = "nothing" This tells the postfix that we are not handling mails for any domains
local_transport = error:Local Mailing is Disabled  tells that postfix is not handling any of the local mails too.
relayhost tells postfix now to forward all the mails destined local or remote to the SmartHost server defined. Make sure that the SmartHost server has configured to receive the mails for.
It is "not mandatory" that in a Null Client configuration there should be a "relayhost". If we are not mentioning any smarthost Postfix will attempt to resolve the MX of the destination of the mail and sends the mail directly.
# vim
# local     unix        n    n    -    -    local
Comment the above derivative to disable the "local" transport feature of Postfix (local mailing).
# postfix reload
    Reload the postfix configuration. Now the postfix server will act as Null Client and all the mails that generates will be forwarded to the smarthost defined. Test the configuration by sending the mail "from" and "to" to the NullClient host and check the logs.

No comments:

Post a Comment

tag ur valuable ideas below