EXIM: Relay to Office 365

Solution 1:

You need a smarthost_auth router (you can make up any name for this), in the routers section (i.e. what begins with begin routers); order is important and seeing how all mail should be sent to the O365 server, put it at the top of the routers:

smarthost_auth:
  debug_print = "R: smarthost for $local_part@$domain"
  driver = manualroute
  domains = ! +local_domains
  transport = smtp_smarthost_auth
  route_list = * o365server.example.com byname
  host_find_failed = defer
  same_domain_copy_routing = yes
  no_more

You can replace the domains line with domains = * if all mail must go to the O365 server; put the right hostname for that server in the route_list line.

Then you need this transport (again I chose the name, change it if you want); put this in the section beginning with begin transports, order is not important:

smtp_smarthost_auth:
  debug_print = "T: remote_smtp_smarthost for $local_part@$domain"
  driver = smtp
  hosts_require_auth = *

Finally you need an appropriate authenticator, after the line begin authenticators. Presumably the config you have already has a cram_md5, plain and login stanza there. E.g. something like this:

cram_md5:
  driver = cram_md5
  public_name = CRAM-MD5
  client_name = MyName
  client_secret = MySecret

fixed_plain:
  driver = plaintext
  public_name = PLAIN
  client_send = ^MyName^MySecret

fixed_login:
  driver = plaintext
  public_name = LOGIN
  client_send = : MyName : MySecret

Of course replace the MyName and MySecret.