I installed Ubuntu desktop 12.04 64bit on my laptop. I used these commands to install a simple web server:

apt-get install apache2

apt-get install php5

apt-get install mysql-server

All is working fine for the sugar crm that I want to be hosted locally. However getting email to be sent out is a real struggle I tried exim4 sendmail and postfix.

I configured and tried a lot so I guess telling you what i tried to make it work would only cause confusion.

I am a newby to ubuntu and the command line, any guidance in getting mail to be sent out is very much appreciated!

  • This probably better belongs to askubuntu.com
    – CodeZombie
    May 26 '13 at 9:35

I installed ssmtp:

sudo apt-get install ssmtp

and used my gmail credentials in the:

gksu gedit /etc/ssmtp/ssmtp.conf


# Config file for sSMTP sendmail
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com


# Where will the mail seem to come from?

# The full hostname

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address

All works fine now!


Please do following steps to send mail from localhost on Ubuntu/Linux through gmail :-

For that you need to install msmtp on Linux/Ubuntu server.

Gmail uses https:// (it's hyper text secure) so you need install ca-certificates

~$ sudo apt-get install msmtp ca-certificates

It will take few seconds to install msmtp package.

Now you have to create configuration file(msmtprc) using , gedit editor.

~$ sudo gedit /etc/msmtprc

Now you have to copy and paste following code in gedit (file you created with above command)

tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt

account default
host smtp.gmail.com
port 587
auth on
user MY_GMAIL_ID@gmail.com
from MY_GMAIL_ID@gmail.com
logfile /var/log/msmtp.log

Don't forget to replace MY_GMAIL_ID with your "gmail id" and MY_GMAIL_PASSSWORD with your "gmail password" in above lines of code.

Now create msmtp.log as

~$ sudo touch /var/log/msmtp.log

You have to make this file readable by anyone with

~$ sudo chmod 0644 /etc/msmtprc

Now Enable sendmail log file as writable with

~$ sudo chmod 0777 /var/log/msmtp.log

Your configuration for gmail's SMTP is now ready. Now send one test email as

~$ echo -e "Subject: Test Mail\r\n\r\nThis is my first test email." |msmtp --debug --from=default -t MY_GMAIL_ID@gmail.com

Please check your Gmail inbox.

For sending mail with php please check https://stackoverflow.com/questions/33969783/phpubuntu-send-email-using-gmail-form-localhost

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy