4

Hello I'm trying to run the following command in my container

mail -s "This is Subject" [email protected] < /path/to/file

How should my dockerfile look so the above command can be executed ?

I tried the following solution

https://stackoverflow.com/questions/40890011/ubuntu-dockerfile-mailutils-install

FROM ubuntu:latest
ENV DEBIAN_FRONTEND="noninteractive"
RUN apt-get update && apt-get install -y mailutils

but I get this error

The command '/bin/sh -c apt-get update && apt-get install -y mailutils' returned a non-zero code: 100

I also tried some examples like this

https://github.com/42technologies/docker-postfix-gmail

FROM ubuntu:14.04

RUN apt-get update
RUN apt-get install -y mailutils
RUN echo "postfix postfix/mailname string gmail.com" | debconf-set-selections
RUN echo "postfix postfix/main_mailer_type string 'Internet Site'" | debconf-set-selections
RUN apt-get install -y postfix

ADD mail.sh /mail.sh
RUN chmod +x /mail.sh

ENTRYPOINT ["/mail.sh"]  

But I don't won't the container to only send emails because I'm customizing a specific container and I just want to enable the sending email features.

1 Answer 1

0

you can modify the mail.sh, only left the enable part. And when you want to send email out just need to run some command. e.g #echo "body example" | mailx -s "subject example" [email protected]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .