It appears that the mail server (SendMail) is not so straightforward in terms of configuration.
so in systems that have SendMail by default, you might have to remove sendmail using the following command:
apt-get --purge remove sendmail
then install postfix which is way easier to configure.
apt-get install postfix
then use the following script to configure the postfix to work with gmail or any google apps Email account.
wget http://www.lolacolay.com/ramon/postfixgmail.sh chmod +x postfixgmail.sh ./postfixgmail.sh
The above script is taken from this post