mirror of
https://github.com/axllent/mailpit.git
synced 2026-04-26 16:56:00 +03:00
[GH-ISSUE #553] Specifying SMTP credentials in MP_SMTP_AUTH env variable not working #357
Labels
No labels
awaiting feedback
bug
docker
documentation
enhancement
github_actions
invalid
pull-request
question
stale
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/mailpit#357
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @zam6ak on GitHub (Aug 16, 2025).
Original GitHub issue: https://github.com/axllent/mailpit/issues/553
Hi
I am running latest Mailpit v1.27.4 in a Docker container and am trying to specify SMTP credentials via environment variable.
However, no matter what combination I try (plaintext, crypt-SHA512) I am getting
DENYmessage in the log...Here is the compose section for my Mailpit container
Here is how I tested (making a cURL call from my PC (host)
cURL command:
cURL log:
And here is SMTP log from Mailpit
If I replace
MP_SMTP_AUTH='user1:password1'and specifyMP_SMTP_AUTH_ACCEPT_ANY=trueeverything works fine...I also tried
MP_SMTP_AUTH='user1:<crypt-sha512-hash-of-password1>'instead of plain password but that did not work either...Are my settings incorrect, or could this be some other issue?
Thanks
Z....
@axllent commented on GitHub (Aug 17, 2025):
OK, so this had me confused too as I was able to replicate what you were experiencing... until I realised what was wrong ~ This is not an issue with Mailpit, it's a problem with your syntax in the docker compose config file.
Using
- MP_SMTP_AUTH='user1:password1'(or even- MP_SMTP_AUTH="user1:password1") you are actually passing Docker the value'user1:password1'including the quotes, which is username ='user1with passwordpassword1'- the quote marks are included as part of the value. You either have to use- MP_SMTP_AUTH=user1:password1(not quoted), OR you can alternatively set it asMP_SMTP_AUTH: user1:password1without the-prefix.Any of these work:
I hope this helps?
@zam6ak commented on GitHub (Aug 17, 2025):
Thanks for the quick response...
This is quite strange as I have other services where environment variables are using
arraysyntax where values after=are quoted.How would you pass 2 or more values in case password had special characters (specifically "space") using this syntax?
As per docs, the space is delimiter for multiple credential pairs...
only way I can think of working around this is to read the values from
.envfile and leverage interpolation...side note:
now that I am able to test w/ credentials, I am noticing that regardless of the credential pairs, I can still use any credentials. I even explicitly set :
and am able to send email using any username and password...
Not sure if this is me doing something wrong so I didn't file it as a separate issue yet...
@axllent commented on GitHub (Aug 18, 2025):
If you are using complicated passwords (or with a password with spaces) then you have two options:
user1:$apr1$f0cpl62q$/WCTZYiEcTIreCdl7cQNu.(you can use a tool like https://www.web2generators.com/apache-tools/htpasswd-generator to encode it)--smtp-auth-file(or envMP_SMTP_AUTH_FILE) [untested with spaces but I assume it should work]I haven't got a clue why some apps work with quotes and others don't, but I suspect those apps which work may trim surrounding quotes in the data. Mailpit is literally just reading in the environment variables presented by Docker, so this seems a limitation in the Docker compose yaml when using arrays. I would advise you use the
MP_SMTP_AUTH: "user1:password1"syntax rather than the- MP_SMTP_AUTH=user1:password1in your compose yaml though as it's less problematic.I also cannot replicate your "side note" observation on my end - if I change my credentials and run your script I get an authentication error. What I can say however is that Mailpit won't wok if you set both
MP_SMTP_AUTHandMP_SMTP_AUTH_ACCEPT_ANY: true, andMP_SMTP_AUTH_ACCEPT_ANY: falseis implied when usingMP_SMTP_AUTH.Hope this helps?
@zam6ak commented on GitHub (Aug 18, 2025):
Thanks for your feedback!