Install sendEmail (simple SMTP client for Linux) on CentOS

I have a lot of servers up and running doing various tasks. They run scripts, and for most of the scripts I want to know if the outcome was good or bad. Especially bad.

The most common and easy way is to send an email for most of the cases, but I don’t want to setup a mailserver such as postfix in order to do it. I prefer to just use a gmail address in order to complete the task easily.

I found an application-utility which does exactly this simple thing. It is written in perl and it is called sendEmail – not to be confused with sendmail. I figured out that because I just install it when I set up a new server, I can’t find any complete instructions and I need to search around every time in order to make it work. Note that you cannot find sendEmail in the usual yum repositories.

So, in order to start, download the sendEmail tar archive:

wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz

Then extract it:

tar -zxvf sendEmail-v1.56.tar.gz

Then copy the sendEmail script to /usr/local/bin. Note that you must have root rights for the operation.

sudo cp -a sendEmail-v1.XX/sendEmail /usr/local/bin

The script needs to be executable, so go make it.

sudo chmod +x /usr/local/bin/sendEmail

Then, go ahead and run:

sendEmail

If everything went fine, the command should produce a usage summary of sendEmail.

So far, so good. But in order to send email via gmail you also need additional libraries which are needed for authentication. The ones missing from me were “Net::SSLeay” and “IO::Socket::SSL”.

As you may have already guessed, these libraries are perl libraries. So in order to install them, run the following commands:

sudo yum install 'perl(Net::SSLeay)'

and

sudo yum install 'perl(IO::Socket::SSL)'

After this, you should be good to go. In order to send an email via Gmail, the command should look like this:

# send an email
sendEmail -v -f $username -s $host -xu $username -xp $password -t $recipient -o tls=yes -u $subject -m $content

This is a line from a bash script that I have written in order to monitor the status of my websites (if they are reachable or non-reachable).

Feel free to use it or contribute to it.

9 thoughts on “Install sendEmail (simple SMTP client for Linux) on CentOS”

  1. I tried to use sendEmail for mail sending from unix platform. i already installed required perl libraries mentioned above. i am getting following error messgae:

    invalid SSL_version specified at /usr/local/share/perl5/IO/Socket/SSL.pm line 525

    it looks some mismatch related with object creation..

    Look for response

    1. You are looking for a response, yet you fail to disclose the version and flavour of unix you are using. Well, how can I help you then? IF you are using CentOS 7, that guide is outdated and I’ve never setup sendEmail on a CentOS 7 so far, so look for another guide.

  2. I am using centos 7. I am getting below error i dont why. I am using same process in centos 6. it works good.

    *******************************************************************
    Using the default of SSL_verify_mode of SSL_VERIFY_NONE for client
    is deprecated! Please set SSL_verify_mode to SSL_VERIFY_PEER
    together with SSL_ca_file|SSL_ca_path for verification.
    If you really don’t want to verify the certificate and keep the
    connection open to Man-In-The-Middle attacks please set
    SSL_verify_mode explicitly to SSL_VERIFY_NONE in your application.
    *******************************************************************
    at /usr/local/bin/sendEmail line 1906.
    invalid SSL_version specified at /usr/share/perl5/vendor_perl/IO/Socket/SSL.pm l ine 415.

Leave a Reply