First of all your SharePoint server should be added to Microsoft online safe sender list, so that SharePoint server can connect and deliver emails to Microsoft Exchange online.
SharePoint by default is configured to send Email over port 25 (default SMTP) but Microsoft online services are configured to receive Emails over port 587.
In order to bridge the gap between these two things, we can use in built feature of Windows Server OS to route Emails
In Short
Configuring Outgoing Email in MSF (Microsoft SharePoint Foundation), MSS (Microsoft SharePoint Server)
SMTP Configuration for Windows Server 2008
Pre - requisites : Need to install IIS 6 Manager.
Open the IIS 6 Manager on your Windows Server 2008 machine.
Go to the DSMTP Virtual Server properties
-> Go to Access,
click on Relay
-> Add the localhost IP 127.0.0.1 and the internal servers IP(192.168 Range) and public IP
and click ok.
->Goto Delivery
-> Click on Outbound security
-> Enable basic authentication, Enter the user name and password for authentication given by MS online
-> On Delivery
-> Outbound Security also enable TLS Encryption
->Click ok
->On Delivery -> Click Outbound connection
-> Set TCP port to 587
->Click OK
->On Delivery
-> Go to Advanced tab
-> Set Fully Qualified domain name of your SharePoint server in the Fully-qualified domain
name.
-> Set smarthost "your microsoft online smarthost"
-> Click OK
-> Click OK to close IIS 6 Manager.
Including IIS6 configuration, you should also do the below SMTP settings in IIS 7
SMTP configuration in IIS 7,
->Open IIS7 Manager
->Click on the Specific Web application where you want to configure outgoing emails.
->Click on SMTP E-mail
->SMTP Server
"localhost", Port 25
->Authentication : not required.
Outgoing Email configuration in SharePoint 2010
Go to Central Admin
Site > Click on Outgoing Email settings.
->In the outbound SMTP server give the Fully qualified domain name of the SharePoint Server.
->From Address > Microsoft online account Email ID.
->Reply-to > Microsoft online account Email ID
Now you should be able to send Emails from SharePoint servers, configure alerts etc.,
For configuring outgoing Emails in MOSS, WSS when the base OS is Windows Server 2003