Install ssmtp package

# apt-get install ssmtp

sign up on Google for a free Gmail account.

# nano /etc/ssmtp/ssmtp.conf

root=user@gawab.com
mailhub=smtp.gawab.com:25
hostname=user@gawab.com
FromLineOverride=YES
AuthUser=user
AuthPass=userpass

# nano /etc/ssmtp/revaliases

root:user@gawab.com:smtp.gawab.com:25

testing:

# echo test | ssmtp -s "test" test@host.tld

edit php.ini:

# nano /etc/php5/apache2/php.ini

[mail function]
; For Win32 only.
;SMTP = localhost
;smtp_port = 25

; For Win32 only.
;sendmail_from = me@example.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = /usr/sbin/ssmtp -t

# /etc/init.d/apache2 reload