Running Sendmail Inside a Container

Note: This document is based on Jelastic version 4.1

Sendmail is a highly popular open source mail transfer agent for UNIX systems, which is commonly delivered in a bundle with the majority of Linux distributions. It supports a plenty of mail transfer protocols (such as SMTP, ESMTP and others), being designed to route emails over the Internet and internal networks.

Jelastic delivers Sendmail included to all of the application servers’ builds (except the IIS ones) by default. However, the ability to run this service in a container depends on a particular hosting providers’ settings - at some platforms, it could be available only in case of a bound Public IPv4 address presence. So, let’s consider how to:

Check Sendmail Availability

In order to discover whether your hosting service provider allows to run Sendmail in containers with internal address only, you can either:
  • send the appropriate request through the Help > Contact Support section at your dashboard

  • or check this manually in a few simple steps for any of your app server containers, following the instruction below:

1. Connect to your account via Jelastic SSH Gateway.

Tip: In case you haven’t performed similar operations before, you need to:

2. Once inside the application server shell, execute the pstree command to display the list of the currently handled processes in a system. Check whether it includes the Sendmail point - it’s presence means that the appropriate service is already run, so you can just start using it immediately.

Otherwise, i.e. in case the appropriate line is absent, proceed to the next section in order to find out how to get the Sendmail activated.

Enable Sendmail

The easiest way to launch Sendmail is to enable Public IP for your application server via the topology wizard (either while environment creation, or, for the already running environment, it can be accessed with the help of the Change environment topology button).

Then just turn on the corresponding switcher at the App Server layer and confirm the changes with the Apply button at the bottom right corner of the wizard frame.

After the confirmation and external IP address attachment, the Sendmail service will be automatically started, so you can start to use it immediately.

Tip:  As an option, you can appeal to your hoster’s Support team and negotiate getting the permission for running Sendmail in a server with no external address attached.

Send a Message via Sendmail

You can discover how Sendmail is working by sending a simple test email. This can be accomplished right from the command line - for that:

1. Connect to your application server (with the Sendmail service already running) via SSH.

2. Execute the following line of code in order to send a letter:

echo "{text}" | sendmail -f {from_address} -v {to_address}

where:
  • {text} - text of your letter, e.g. Jelastic - Unlimited PaaS and Container-Based IaaS
  • {from_address} - sender email address in the mail@example.com format
  • {to_address} - recipient email address (in the same mail@example.com format)

3. In order to ensure everything works as intended, access an email account you’ve sent the message to and check the inbox for a new message (its delivery can take up to a couple of minutes)

Great! Now you can be sure that Sendmail is ready for work. And in case you are interested in more detailed configurations and far complex solutions, that can be implemented by means of this tool, please refer to the official documentation.

If you face any issues while running or configuring Sendmail, feel free to appeal for our technical experts’ assistance at Stackoverflow.