Install SMTP role on one of the Servers in the domain which has access to internet, since we need to connect to smtp.office365.com this is must.

Configuring SMTP service so that it can talk to office365 smtp

Open --> IIS 6.0 Manager --> right click on SMTP --> properties

2.1 First we will configure the Access, we don’t have much to configure in this. Check authentication is set to anonymous

2.2 Next click on connection button and you can select which servers can connect to this virtual server, by default it is set to accept all. If you need you can modify as per your orgs security policies

2.3 Next click on relay, here you can select which computer can relay through this SMTP. If you need that any computer / server can relay through this, select all except the list below option

2.4 Next click on Messages tab, here we don’t have to change anything except if you need to change the badmail directory i.e. where SMTP store any email that it fails to deliver due to one or the other reason.

2.5 Next click on delivery tab à outbound security, here chose basic authentication and provide a username and password, remember this user should have a valid exchange online mailbox. Also make sure you check TLS encryption here

2.6 Next click on outbound connections, here we can specify the port as 25 or 587 and leave rest as it is

2.7 Next click on Advanced , here you can provide FQDN name of your domain and smart host which should be set to smtp.office365.com