sendEmail bug with SSL encrypted connection

10 Febbraio 2015

As reported on Debian Bug report site, if you try to send email using sendEmail over a SSL encrypted connection, You're gonna have a bad time. sendEmail require to use a TLS connection on port 587, but this configuration doesn't work with gmail.com nor with many other hosting provider. So what? This is an annoying bug and You need to modify some core files of sendEmail program to be able to send email over SSL. This guide will follow You through the necessary steps to have sendEmail working with SSL connection.
First of all, be sure You have installed on your system the lastest SSL socket libraries and perl; run from a shell this command (assuming your system is Debian based):
sudo apt-get install libio-socket-ssl-perl libnet-ssleay-perl perl
The command to send email using gmail.com smtp server is like this and will ends with an error like: "ERROR: Timeout when trying to connect to smtp.gmail.com" or: "invalid SSL_version specified at /usr/share/perl5/IO/Socket/SSL.pm"
sendEmail -o tls=yes -f username@gmail.com -t TO_ADDRESS -s smtp.gmail.com:587 -xu username@gmail.com -xp PASSWORD -u "Hello from sendEmail" -m "How are you? I'm testing sendEmail from the command line."

My version of sendEmail is 1.56
Heads Up! You need root access to do this steps!

Edit /usr/share/perl5/IO/Socket/SSL.pm

You need to modify two separate files. I know that editing files installed from a package is bad, but this is only a temporary workaround.
First file is located in /usr/share/perl5/IO/Socket/ and is named SSL.pm. Open the file with your favourite editor with root access. In my case:
sudo gedit /usr/share/perl5/IO/Socket/SSL.pm

Go to line 1490 and search for this piece of code: m{^(!?)(?:(SSL(?:v2|v3|v23|v2/3))|(TLSv1[12]?))$}i.
Just modify it with this: m{^(!?)(?:(SSL(?:v2|v3|v23|v2/3))|(TLSv1[12]?))}i
Save and You're done with this one.

/usr/bin/sendemail

Second file is sendemail itself :O. You can find it in /usr/bin
Go to line 1907 (this may be different, remember that my version is 1.56) and search for this: if (! IO::Socket::SSL->start_SSL($SERVER, SSL_version => 'SSLv23:!SSLv2')) {
Cancel SSLv23:!SSLv2 and insert SSLv3
Restart sendEmail
sudo restart service sendemail

Now if You run the first command I wrote at the beginning of this post, You'll have a message sent correctly.


X
THE END