in All Posts Basic ~ read.
Creating Mail Relay Authenticated By IP (Outgoing)

Creating Mail Relay Authenticated By IP (Outgoing)

I used Centos 6.8 to configure a Mail Relay.

1st step -

Install exim in your server :

yum install exim-mysql -y

Usually centos default MTA is postfix, so we need to change the default MTA to exim, with command below :

alternatives --config mta

It will bring you below selection :

There are 2 programs which provide 'mta'.

Selection Command
* 1 /usr/sbin/sendmail.postfix
+ 2 /usr/sbin/sendmail.exim

Enter to keep the current selection[+], or type selection number:

Choose 2 to use exim as the default MTA, (I have chosen 2 in my example).

service postfix stop

chkconfig postfix off

service exim start

chkconfig exim on

Now we need to change the exim configuration at /etc/exim/exim.conf

Change to below :

primary_hostname = <- my mail relay hostname
hostlist relay_from_hosts = : (add your mail server IP here) <- to make sure that you are allowed to relay in this server

Then find a section called "router" in the configuration and make sure the router is set as below :


 driver = dnslookup

 domains = ! +local_domains

 transport = remote_smtp

 ignore_target_hosts = :


Above config will tell route all email, and send it for you to the recipient.

But we must make sure that your mail server know where to relay the  server to, so you need to login to your mail server (origin server).

Then edit the exim config for smarthost as below :


 driver = manualroute

 domains = ! +local_domains

 transport = remote_smtp

 route_list = *    <- this will guide my mail server to relay email to my new Mail Relay Server



After completed all above steps, try to send using your origin server to anyone.You will got the header of the email as below :

Return-Path: [email protected]

Received: from *.*.*.*(LHLO (*.*.*.*) by with LMTP; Fri, 6 Jan 2017 10:55:17 +0800 (MYT)

Received: from ( [*.*.*.*])

	by (Postfix) with ESMTP id 7EFE4516966A

	for <[email protected]>; Fri,  6 Jan 2017 10:55:17 +0800 (MYT)

X-ASG-Debug-ID: 1483671316-068b3e1093354110001-4XlEqv

Received: from ([*.*.*.*]) by with ESMTP id OFtS3gY6HqFmSdZT for <[email protected]>; Fri, 06 Jan 2017 10:55:16 +0800 (MYT)

X-Barracuda-Envelope-From: [email protected]

X-Barracuda-Apparent-Source-IP: *.*.*.*

DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;; s=mail;

	h=Message-ID:From:Date:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:To; bh=1bP+QR4oOJI80qfwgQhGi2RMJffC7P++shP6eV7AOkU=;


To: [email protected]

Subject: Test

As you can see above, it stated that it received from my Mail Relay (

// reference //Initialize ghostHunter