How can I use Sendmail Inside a Container

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.

Cloudjiffy delivers Sendmail included to all of the application servers' builds (except the IIS ones) by default. It could be available only in case of a bound public IP address presence. So, let’s consider how to:

  • check the Sendmail availability
  • enable Sendmail in case it is not run
  • send a test message

Check Sendmail Availability

To run Sendmail in containers with internal address only, there are two ways:

  • send the appropriate request through the Help > Contact Support section at the dashboard

                                                          

  • or check this manually in a few simple steps for any of the app server containers, following the instruction below:
  1. Connect to the account via CloudJiffy SSH Gateway.
  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 I 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 the 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 increase the no. of public IPV4 to 1 in 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 I can start to use it immediately.

 

Send a Message via Sendmail

I 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 the 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 the 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)


Was this article helpful?

mood_bad Dislike 0
mood Like 0
visibility Views: 1513