Here is a way to set exim as a relay for Exchange Online
cat /etc/exim4/passwd.client # password file used when the local exim is authenticating to a remote # host as a client. # # see exim4_passwd_client(5) for more documentation # # Example: ### target.mail.server.example:login:password *:user@shebangthedolphins.net:Password
dc_eximconfig_configtype='smarthost' smarthost='shebangthedolphins.net' dc_other_hostnames='' dc_readhost='' dc_relay_domains='*' dc_minimaldns='false' CFILEMODE='644' dc_use_split_config='false' dc_hide_mailname='false' dc_mailname_in_oh='true' dc_localdelivery='mail_spool' dc_local_interfaces='' dc_smarthost='smtp.office365.com:587' dc_relay_net='192.168.0.59;192.168.0.221;192.168.0.48' #Normally only allow this IPs but doesn't seems to work. So use netfilter (see under).
root:~# update-exim4.conf
iptables -t filter -F iptables -t filter -A INPUT -s 192.168.0.59 -p tcp --dport 25 -j ACCEPT iptables -t filter -A INPUT -s 192.168.0.221 -p tcp --dport 25 -j ACCEPT iptables -t filter -A INPUT -s 192.168.0.48 -p tcp --dport 25 -j ACCEPT iptables -t filter -A INPUT -s 192.168.0.0/24 -p tcp --dport 25 -j REJECT
Contact :