How to setup centos mail relay to exchange server

A classic setup!

To set up a CentOS mail relay to an Exchange Server, you'll need to configure your CentOS machine as a mail relay server and then configure your Exchange Server to use the CentOS relay server. Here's a step-by-step guide to help you achieve this:

Step 1: Install and configure Postfix on CentOS

  1. Install Postfix on your CentOS machine:
    sudo yum install postfix
  2. Configure Postfix to listen on port 25 (the default SMTP port):
    sudo nano /etc/postfix/main.cf

    Add the following lines at the end of the file:

    mydestination = localhost
    mynetworks = 127.0.0.0/8 [::1]/128
    smtpd_recipient_restrictions = permit_mynetworks, reject_unauth_destination
  3. Restart Postfix to apply the changes:
    sudo systemctl restart postfix

Step 2: Configure your Exchange Server to use the CentOS relay server

  1. On your Exchange Server, go to the "Server Configuration" section and click on "Mail Flow" > "Send Connectors".
  2. Click on "New Send Connector" and select "Internet" as the connector type.
  3. Enter a name for the connector (e.g., "CentOS Relay Server") and select "Custom" as the "Smart Host" type.
  4. Enter the IP address or hostname of your CentOS relay server (e.g., centos-relay-server.example.com) in the "Smart Host" field.
  5. Set the "Port" to 25 (the default SMTP port).
  6. Click "Next" and then "Finish" to create the send connector.

Step 3: Configure your CentOS relay server to forward mail to your Exchange Server

  1. On your CentOS relay server, edit the Postfix configuration file:

    sudo nano /etc/postfix/main.cf

    Add the following lines at the end of the file:

    mydestination = localhost
    mynetworks = 127.0.0.0/8 [::1]/128
    smtpd_recipient_restrictions = permit_mynetworks, reject_unauth_destination
    relayhost = [Exchange Server's FQDN]:25

    Replace [Exchange Server's FQDN] with the fully qualified domain name of your Exchange Server (e.g., exchange-server.example.com).

  2. Restart Postfix to apply the changes:

    sudo systemctl restart postfix

Step 4: Test the setup

  1. Send an email from your CentOS relay server to an external recipient (e.g., [email protected]).
  2. Verify that the email is relayed to the Exchange Server and then forwarded to the external recipient.

That's it! Your CentOS relay server should now be configured to forward mail to your Exchange Server.