'Docker: Ubuntu base image send Email using mail & mailx

I'm trying to send mail using Mail & Mailx from my AKS container. I am using Ubuntu as a base image and have installed mailutils.

using the below command

RUN apt-get install -y mailutils

and tried the below command

echo "This is message body" | mail -s "This is Subject" [email protected]

and it is throwing an error

Dead Letter not found

My SMTP configuration is

    mailhost: mailhost.demo.com
    port: 25 
    auth:  
    username:  
    password:

however I have not configured/added anything in the docker file.

What should I do in the docker file so that I can send the email using Mail & Mailx?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source