config ssmtp as mail forwarder on php.ini mail function()

Install ssmtp package

# apt-get install ssmtp

sign up on http://www.gawab.com (they give us smtp server for free)

# 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

using joomla contact form, this tool works 100%.

Advertisements

3 thoughts on “config ssmtp as mail forwarder on php.ini mail function()”

  1. Thanks for the nifty guide.

    I think you made an error on the hostname entry though.

    I fixed it by remove the “user@” part and changing it to:
    hostname=gawab.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s