Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot set SMTP addr with env var #25

Open
unixslayer opened this issue Dec 13, 2018 · 6 comments
Open

cannot set SMTP addr with env var #25

unixslayer opened this issue Dec 13, 2018 · 6 comments

Comments

@unixslayer
Copy link

With mhsendmail installed on application container and MailHog on another, I'm unable to set smtp addr using ENV vars. mhsendmail keeps trying to use localhost:1025.

docker-compose.yml:

services:
  fpm:
    container_name: fpm
    image: php:7.2-fpm
    environment:
      - MH_SENDMAIL_SMTP_ADDR="mailhog:1025"
  mailhog:
    container_name: mailhog
    image: mailhog/mailhog
    ports:
      - "1025:1025"
      - "8025:8025"

php.ini:

sendmail_path = /usr/local/bin/mhsendmail

test call run from fpm container:

php -r "\$from = \$to = '[email protected]'; \$x = mail(\$to, 'subject'.time(), 'Hello World', 'From: '. \$from); var_dump(\$x);"

result:

error sending mail
dial tcp 127.0.0.1:1025: getsockopt: connection refused
bool(false)

running the same test from host works fine.

@Santana1053
Copy link

I am also experiencing this issue. A temporary fix would be to set

sendmail_path = "/usr/local/bin/mhsendmail --smtp-addr=mailhog:1025"

@karlsminton
Copy link

@Santana1053 I'm trying this method but not having any luck with it.

@manuelcanepa
Copy link

Same here. If use the local ip instead of mailhog its works. Like this:
sendmail_path = "/usr/local/bin/mhsendmail --smtp-addr=172.30.0.4:1025"

@brammeleman
Copy link

Looks like this has been fixed in pull request #12, but is isn't in the released binaries. You can use the environment variable MH_SENDMAIL_SMTP_ADDR to set the smtp server. If you create a sendmail symlink that points to mhsendmail, you can send mail from scripts without any configuration changes.
The other environment variable that you can set is MH_SENDMAIL_FROM.

@stefumies
Copy link

Its July 2022 and this still isn't in the binaries?

@ParMesSoins
Copy link

ParMesSoins commented Dec 17, 2024

i get the same problem.
Install by this way resolve the problem:

RUN curl -LkSso /usr/bin/mhsendmail 'https://github.com/mailhog/mhsendmail/releases/download/v0.2.0/mhsendmail_linux_amd64'&& \
    chmod 0755 /usr/bin/mhsendmail && \
    echo 'sendmail_path = "/usr/bin/mhsendmail --smtp-addr=mailhog:1025"' > /usr/local/etc/php/php.ini;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants