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

MAILDEV_AUTO_RELAY environment variable ignored #327

Open
peterfarrell opened this issue Nov 17, 2020 · 11 comments
Open

MAILDEV_AUTO_RELAY environment variable ignored #327

peterfarrell opened this issue Nov 17, 2020 · 11 comments
Labels

Comments

@peterfarrell
Copy link

I have MAILDEV_AUTO_RELAY set to no value using the docker beta 3 and auto relay is not enabled even though I have rules set. How do I enable auto relay without specifying an email address?

@peterfarrell
Copy link
Author

I rebuilt the docker image available from registry.docker.com and added --auto-relay to:

CMD ["--web", "1080", "--smtp", "1025", "--auto-relay"]

And the relay with rules works. It appears that using MAILDEV_AUTO_RELAY with a zero length string as an env var is ignored.

@Maxwell2022
Copy link

Maxwell2022 commented Dec 10, 2020

I had the same issue, you can just append configuration to the docker run command:

sudo docker run -d \
    -p 1080:80 \
    -p 1025:25 \
    --entrypoint=bin/maildev \
    djfarrelly/maildev \
        --web 80 \
        --smtp 25 \
        --web-user admin \
        --web-pass xxxxx \
        --incoming-user admin \
        --incoming-pass xxxxxx

@peterfarrell
Copy link
Author

In my case, I can't modify the entrypoint when pulling from the docker registry and deploying on a container platform. I had to rebuild the image and push a custom image.

@djfarrelly djfarrelly added the bug label Jan 6, 2021
@djfarrelly
Copy link
Member

@Maxwell2022, I see you're specifying the entrypoint. Do you or @peterfarrell think that the Dockerfile should just switch to using ENTRYPOINT or CMD and not both?

Also @peterfarrell, should we adjust the documentation to say that the environment variable for MAILDEV_AUTO_RELAY should be MAILDEV_AUTO_RELAY=true instead of empty string?

@peterfarrell
Copy link
Author

@djfarrelly IIRC, tried setting the value of MAILDEV_AUTO_RELAY to true however it tries to relay to an email address called true. What I'm trying to do is turn on auto relay but only relay to the emails defined in our MAILDEV_AUTO_RELAY_RULES file instead of a single global catch-all optional address.

This does not work -- it ignores the rules.json file entirely and does not rely:

MAILDEV_AUTO_RELAY=
MAILDEV_AUTO_RELAY_RULES=/config/rules.json

This does not work -- it tries to rely to an email address named true:

MAILDEV_AUTO_RELAY=true
MAILDEV_AUTO_RELAY_RULES=/config/rules.json

This works when you pass --auto-relay as part of the CMD or ENTRYPOINT as it relays to the emails listed on the rules file.

MAILDEV_AUTO_RELAY_RULES=/config/rules.json

@peterfarrell
Copy link
Author

@djfarrelly I think it may be with how boolean args in env vars are being parsed as mentioned in this comment:

#315 (comment)

@reischlfranz
Copy link

Just stumbled across this. Any updates?

@peterfarrell
Copy link
Author

@reischlfranz None

@dada051
Copy link

dada051 commented Jul 8, 2022

When using MAILDEV_AUTO_RELAY docker var, it's set to an empty string (I think it's not the case when using "--auto-relay". And the code (in index.js file) check if the var is a string or not, but doesn't check is the string is empty. Adding this check can fix I think.
Another solution is discussed in #315

@Acsigen
Copy link
Contributor

Acsigen commented Nov 21, 2022

For me it works by by commenting out MAILDEV_AUTO_RELAY and MAILDEV_AUTO_RELAY_RULES env vars and adding the following inside docker-compose.yml

command: ["--auto-relay", "--auto-relay-rules=<path-to-rules.json>"]

Be careful though, the rule file inside the docs of this repository is not valid, I made a PR to fix that issue.

@nacesprin
Copy link

But if in order to get working auto-relay is that /data directory must be empty, when I need to restart the service for any reason, all previous /data/*.eml files will be deleted, so the email history will be lost.
Is it right?

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

No branches or pull requests

7 participants