Walker News

Compile Mailsend the Command-line SMTP client For Raspberry Pi

For people who want to automate Linux shell script or Windows batch file to send authenticated email (not via SMTP relay method), you’ll love this open-source, command-line SMTP email client.

The author published both binary and source file for Linux and Windows on Google Code. You’ll need to compile the binary, however, if the compiled program provided by the author doesn’t suit your platform (e.g. ARM platform / Raspberry Pi) or requirement (modify the source file to hardcode email login ID/password).

With reference to Linux compilation guideline, these are the steps I used to compile mailsend for my Raspberry Pi powered by Raspbian OS (version 7/wheezy; kernel 3.10.27+ #630 PREEMPT Fri Jan 17 19:44:36 GMT 2014 armv6l GNU/Linux):

1. Let’s go straight to root login:
sudo su - root

2. Download the stable mailsend source files (v1.16) by using wget. If the link is broken by the time you read this post, or to check is the latest version available, please visit the mailsend project homepage.
wget https://mailsend.googlecode.com/files/mailsend1.16.tar.gz

3. Decompress the gzipped tar archive file to extract the source file directory:
tar -zxvf mailsend1.16.tar.gz

4. Change directory to mailsend source file directory:
cd mailsend1.16

5. Confirm the libssl-dev package (which provides OpenSSL development library and header files) is already installed properly on your Raspbian OS:
dpkg-query -s libssl-dev

By default, this libssl-dev package is not installed. So, let’s download and install it by using apt-get:
apt-get install libssl-dev

6. Let’s start to compile mailsend for the Raspbian/ARM platform. Firstly, execute the configure shell script:
/bin/sh ./configure --with-openssl=/usr

This command is optional; only required if you want to rebuild mailsend:
make clean

Final step – compile the mailsend executable program file:
make; echo $?

Suppose the compilation completes successfully, the “echo $?” executed immediately after “make” should show 0, and the executable mailsend program should have created in the source file directory.

Now, let’s test it – uses the mailsend to login Gmail and send an authenticated email to recipient at Hotmail.com (replace the red color text accordingly):
./mailsend -smtp smtp.gmail.com -port 587 -auth -starttls -f sender@gmail.com -t recipient@hotmail.com -sub "test subject" -M "test message body" -user "username" -pass "password"

You can also run mailsend -h or mailsend -example to get help of all its option switches and examples of usage.

If it works, you can copy the binary program to a directory expected by your shell scripts that use it to send authenticated email via SMTP protocol.

Custom Search

2016  •  Privacy Policy