Hi,
The command to execute something in a container is -
docker exec <container_id/container_name> <instruction/cmd to be executed>
In your case, you are trying to send a mail I believe, so:
docker exec -d <container_name> sendmail -f user@yahoo.com
This should run the command in a detached state/ run the process in the background.
In case you want your stdin to be open, replace -d with -i.
sendmail is an utility I believe, incase it is not running, run the command from inside the container and if needed install the sendmail util:
docker exec -i -t <container_name> /bin/bash (or /bin/sh)
This tells docker to run it in an interactive mode, gives you back a tty/terminal and runs the /bin/bash command to provides you a bash terminal basically.
Run the cmd from the terminal and check :)
Also check the root process inside the container : PID 1
The command started using docker exec only runs while the container’s primary process (PID 1) is running, and it is not restarted if the container is restarted.
ref : https://docs.docker.com/engine/reference/commandline/exec/