0

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:

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.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
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
DATA
354 Enter mail, end with "." on a line by itself
Hello
.
250 2.0.0 s9VITGpm030795 Message accepted for delivery
daniel9x
  • 755
  • 2
  • 11
  • 28
  • That ID is also used as the hostname of the container. You're not really dealing with a Docker problem here, but with a PHP problem. You should post the code that ends that email. – Thomas Orozco Oct 30 '14 at 22:01

1 Answers1

0

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: foo@bar.com\r\n"...

mgaido
  • 2,987
  • 3
  • 17
  • 39
  • Hi there, thanks for the reply. I am using the PHP mail function and there is a "From:" value that is passed into this function. My php.ini's SMTP server settings are the same as another environment I have that appears to be working, which is why I suspect there's an issue with my docker base container configuration, but as a relative noob...I'm not sure what else to try. – daniel9x Oct 31 '14 at 13:46
  • could you try to telnet from the container to port 25 of your smtp server and send a mail with it? what does it happen in that case? – mgaido Oct 31 '14 at 15:52
  • Yeah, if I try to send a test e-mail via the command line when I am inside the docker container I get the same error. Clearly I don't have sendmail configured correctly in my container. I'm not exactly sure how to telnet to port 25. Can you share an example? – daniel9x Oct 31 '14 at 15:59
  • Here you can find an example of how to do it: http://www.yuki-onna.co.uk/email/smtp.html Please try and then share what is the result – mgaido Oct 31 '14 at 16:12
  • Hi mark, thanks for the reference. I have modified my question accordingly. – daniel9x Oct 31 '14 at 20:18
  • So it seems that your problem is not strictly related to the container, but to your PHP and Apache settings... Your e-mail could not be received because it is likely to be marked as spam... I think that you should look at your apache settings, maybe there is something wrong there – mgaido Nov 01 '14 at 13:50