Docker PHP / Apache Container – Sendmail 553 Error “Domain of Sender Address does not exist” when trying to send mail

I’m having trouble sending e-mail on my PHP/Apache docker container via sendmail. I’m wondering if someone has a simple, straight forward solution. I am not a systems/server expert by any far stretch and my smtp/sendmail expertise is equally underwhelming. Thanks in advance for the help.

Below is the error I’m recieiving:

  • Deploy local repo to Docker container without building image
  • Anaconda Dockerimages
  • Why do Spring Cloud Netflix applications deployed on Docker containers require explicitly setting eureka.instance.hostname?
  • Dokku DigitalOcean Deploy (Cannot access Rails Sample App)
  • All images and containers disappeared after host kernel downgrade
  • “Already connected” Exception when running jersey application inside docker container
  • sendmail: 553 5.1.8 <apache@a0aca7313106>... Domain of sender address apache@a0aca7313106 does not exist

    Clearly apache is my user, and that stuff to the right is my docker container ID. There is a “From:” header value within the pHp Mail parameters being passed, so not sure why it’s defaulting to this.

    As requested by the comment below, I am adding the “mail” function that is being used. I can confirm there is data within this function, specifically the “$this->headers” which contains a From address.

    It should be noticed that I am running the exact same code in a non-containerized environment, and the e-mail gets sent fine so I believe it’s a container configuration issue. These are the areas of the php.ini that I have modified. Is there something else I should be looking for?

    [mail function]
    ; For Win32 only.
    SMTP = localhost
    smtp_port = 25

    I changed “localhost” to the smtp server listed on my non-containerized environment, restarted apache in the container, but still recieved the error message above.

    I am able to connect to my external SMTP server via telnet using the reference listed in the comments below (thanks @mark91). This is my output/transcript. I should mention that my e-mail was never actually received, however (I listed myself as the recipient). I masked the info with *******’s

    telnet smtp.service.******* 25
    Trying *******...
    Connected to *******.
    Escape character is '^]'.
    220 ******* ESMTP smtp.service Fri, 31 Oct 2014 14:29:16 -0400
    HELO *******
    250 ******* Hello [*******], pleased to meet you
    MAIL FROM: *******
    250 2.1.0 *******... Sender ok
    RCPT TO: *******
    250 2.1.5 *******... Recipient ok
    354 Enter mail, end with "." on a line by itself
    250 2.0.0 s9VITGpm030795 Message accepted for delivery

  • Docker node express volume changes in the host not reflected in the container
  • How to deploy docker file on other server
  • Adding services in different consul clients running on same host
  • How to ensure certain scripts on the host system are present inside the Docker container when the container starts?
  • Why Is Apache The Primary Webserver In Docker Containers (for PHP)
  • How to do --rm and --restart in dockerfile?
  • One Solution collect form web for “Docker PHP / Apache Container – Sendmail 553 Error “Domain of Sender Address does not exist” when trying to send mail”

    How are you sending this e-mail in PHP? At least, you might configure correctly your php.ini file in order to put as smtp server the right value. Moreover, if you are using the PHP mail function, you should put as $header parameter a string containing “From:\r\n”…

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.