Walker News

How To Compile Mailsend For Windows 8 With OpenSSL Static Library?

It’s easy to compile mailsend for Raspberry Pi/Raspbian, but it took me few days to figure out how to make a static build of mailsend.exe for Windows platform, from modified source code that hardcodes the SMTP credential and recipients.

So, here is the guide I used to build mailsend with statically-linked OpenSSL library.
This tutorial is tested on 64-bit Windows 8.1, using the latest Microsoft Visual Studio Express 2013 For Windows Desktop, OpenSSL 1.0.1f, mailsend 1.16, and ActivePerl Community Edition 5.16.3. Besides Windows 8.1, I’ve also tested it successfully on 32-bit Windows 7. FYI.

1. Download and install ActivePerl, 7-zip, and Visual Studio Express (containing Visual C++ language compiler).

2. Download the latest stable mailsend 1.16 and OpenSSL 1.0.1f source code archive files.

3. Create C:\tmp folder and then use 7-zip to extract folder from the compressed tar.gz archive files (openssl-1.0.1f.tar.gz and mailsend1.16.tar.gz) to C:\tmp folder.

4. Open the “Developer Command Prompt for VS2013” – a shortcut that runs “VsDevCmd.bat” batch file to configure environment variable setup related to Visual Studio Express compilers and toolkits (such as nmake, the Microsoft Program Maintenance Utility).
From next step onwards, all given commands are to be executed in this “special” Command Prompt window:
A special Command Prompt to execute Visual Studio Express 2013.

5. Create the OpenSSL related folders:
mkdir C:\OpenSSL
mkdir C:\OpenSSL\bin
mkdir C:\OpenSSL\lib
mkdir C:\OpenSSL\include
mkdir C:\OpenSSL\include\OpenSSL

6. Change working directory (if you get path not found error, refer to step-3):
cd C:\tmp\openssl-1.0.1f

7. Compile the OpenSSL static library for 32-bit Windows platform.
NOTE: that “prefix” value is not a typo – it’s C:/OpenSSL not C:\OpenSSL.

The last nmake command is to verify the compilation status.
perl Configure VC-WIN32 no-asm enable-static-engine --prefix=c:/OpenSSL


nmake -f ms\nt.mak

nmake -f ms\nt.mak test

8. Copy the OpenSSL library files to respective C:\OpenSSL folders:
copy /b inc32\openssl\*    C:\OpenSSL\include\OpenSSL
copy /b out32\ssleay32.lib C:\OpenSSL\lib
copy /b out32\libeay32.lib C:\OpenSSL\lib
copy /b out32\openssl.exe  C:\OpenSSL\bin

9. Change working directory (again, refer to step-3, if you get path not found error):
cd C:\tmp\mailsend1.16

10. Showtime! Assume you’ve done the customization in mailsend source file (e.g. main.c), this step is to compile a stand-alone mailsend.exe program file!
It’s a stand-alone program, as it embeds all the required OpenSSL functions. Thus, this mailsend.exe can execute even without the presence of libeay32.dll and ssleay.dll in its working directory).

The “nmake clean” is optional during first-time compilation, but is recommended for subsequent compilations:
nmake -f Makefile.nmake clean
nmake -f Makefile.nmake

Now, let’s test the compiled program file:
mailsend.exe -example

With reference to previous post, my customized version of mailsend.exe should able to send this test email with attachment file to my Outlook.com mailbox:
mailsend -sub "test subject" -attach "ErrLog.log,text/txt,a" -M "test msg"

Custom Search

  1. Kidmar 24-04-14@16:36

    Wow. I’m really impressed by this guide: easy, clear and complete. Thank you.
    I’ve used it to compile successfully under windows server 2012 R2, with visual studio express desktop 2013.
    I’ve built the latest source available (mailsend 1.17b15 and OpenSSL 1.0.1g).

2016  •  Privacy Policy