Small smtp email server client on desktop

You are here

I need a small smtp client so I could send emails from my Drupal development machine. By using the package msmtp-mta this can be achieved. Firstly install the software, in this example Ubuntu will be used but from what I can see all Unix flavours have this package

~$  sudo apt-get install msmtp-mta

After it is installed then configuration is needed this can be by creating a file called msmtprc and adding some configuration.

After installing it we need to create a configuration file for it. Create a new file by opening vim or nano in the terminal

~$ sudo vim /etc/msmtprc

Then add the configuration you need to access your email smtp server. In this example we will use the Google smtp servers.

# This is the default service you can add others if you like
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt

# Email account that needs access credentials
account default
port 587
auth on
password emailAccountPassword

These need to be your Google login details. Now that it is complete you need to see the file permissions so that other software packages can access it

~$ sudo chmod 0644 /etc/msmtprc

Test to see if msmtp-mta works

~$ echo -e "Subject: Test Mail\r\n\r\nThis is a test mail" |msmtp --debug --from=default -t

Adding msmtp-mta to php

If it is now working you will receive an email. What we need to achieve now is getting the php engine to see the login details and execute smtp client. First we need to find where msmtp-mta is

~$ which msmtp

remember the path because we need to tell the php engine now open php configuration file

# This is ubuntu but your path could be different
~$ sudo vim /etc/php5/apache2/php.ini

In the file you need to find the line that says sendmail_path and then add where the smtp client is, which for Ubuntu is

sendmail_path = '/usr/bin/msmtp -t'

Now restart apache or your web server to start the php engine

~$ sudo service apache2 restart