Sending emails using IP address per domain in exim
Перейти к навигации
Перейти к поиску
To be able to send mails via different IP per domain, You need to do the following changes in the /etc/exim.conf file:
Find the remote_smtp: part, and add line
interface = "${lookup{$sender_address_domain}lsearch{/etc/virtual/domainips}{$value}}"
It should look something like: exim.conf
remote_smtp:
driver = smtp
interface = "${lookup{$sender_address_domain}lsearch{/etc/virtual/domainips}{$value}}"
File /etc/virtual/domainips syntax:
domain.tld: ip.add.re.ss
That’s it. Create the domainowners file, restart exim, and You are all set!
script for automatic add domain/ip to domainips file
populateDomainIPs.sh
#!/bin/sh
LIST=`/bin/cat /etc/virtual/domainowners | tr -d ' '`
echo -n '' > /etc/virtual/domainips
for LINE in $LIST; do
USER=`echo $LINE | cut -d: -f2`
DOMAIN=`echo $LINE | cut -d: -f1`
if [ -f "/usr/local/directadmin/data/users/$USER/domains/$DOMAIN.conf" ]; then
IP=`/bin/grep 'ip=' /usr/local/directadmin/data/users/$USER/domains/$DOMAIN.conf | cut -f2 -d=`
[ -z $IP ] || echo "$DOMAIN: $IP" >> /etc/virtual/domainips
fi
done
exit 0;
note: You may add this script to cron, for automatic ‘domainips’ updates.