[GH-ISSUE #81] How to use variables instead of config file #17

Closed
opened 2026-02-26 18:32:58 +03:00 by kerem · 4 comments
Owner

Originally created by @HakunMatat4 on GitHub (Jul 13, 2022).
Original GitHub issue: https://github.com/decke/smtprelay/issues/81

First of all, thank you for this gold tool :)

Long story short, everything has been fine via Docker and Kubernetes.
But I do require to use variables instead of config files and I am lost a bit.

The config files does mention:

All config parameters can also be provided as environment
; variables in uppercase and the prefix "SMTPRELAY_".
; (eg. SMTPRELAY_LOGFILE, SMTPRELAY_LOG_FORMAT)

So, I would have something like this:

SMTPRELAY_LISTEN = starttls://127.0.0.1:587 
SMTPRELAY_LOCAL_CERT = /etc/smtprelay/tls_pem.pem 
SMTPRELAY_LOCAL_KEY = /etc/smtprelay/tls_key. 
SMTPRELAY_LOCAL_FORCETLS = true 

The problem I am having is how to convert /usr/local/bin/smtprelay -config /etc/smtprelay/smtprelay.ini to use the above.
I would try it like /usr/local/bin/smtprelay SMTPRELAY_LISTEN = starttls://127.0.0.1:587 SMTPRELAY_LOCAL_CERT = /etc/smtprelay/tls_pem.pem but it fails and use its own internal config..

I have also tried something like /usr/local/bin/smtprelay SMTPRELAY="127.0.0.1:25" SMTPRELAY_LOGFILE="/var/log/smtprelay.log" but it again ignores it and uses its internal config.

I cannot find much reference about how to use those variables.

Thank you

Originally created by @HakunMatat4 on GitHub (Jul 13, 2022). Original GitHub issue: https://github.com/decke/smtprelay/issues/81 First of all, thank you for this gold tool :) Long story short, everything has been fine via Docker and Kubernetes. But I do require to use variables instead of config files and I am lost a bit. The config files does mention: ``` All config parameters can also be provided as environment ; variables in uppercase and the prefix "SMTPRELAY_". ; (eg. SMTPRELAY_LOGFILE, SMTPRELAY_LOG_FORMAT) ``` So, I would have something like this: ``` SMTPRELAY_LISTEN = starttls://127.0.0.1:587 SMTPRELAY_LOCAL_CERT = /etc/smtprelay/tls_pem.pem SMTPRELAY_LOCAL_KEY = /etc/smtprelay/tls_key. SMTPRELAY_LOCAL_FORCETLS = true ``` The problem I am having is how to convert `/usr/local/bin/smtprelay -config /etc/smtprelay/smtprelay.ini` to use the above. I would try it like `/usr/local/bin/smtprelay SMTPRELAY_LISTEN = starttls://127.0.0.1:587 SMTPRELAY_LOCAL_CERT = /etc/smtprelay/tls_pem.pem` but it fails and use its own internal config.. I have also tried something like `/usr/local/bin/smtprelay SMTPRELAY="127.0.0.1:25" SMTPRELAY_LOGFILE="/var/log/smtprelay.log"` but it again ignores it and uses its internal config. I cannot find much reference about how to use those variables. Thank you
kerem closed this issue 2026-02-26 18:32:58 +03:00
Author
Owner

@decke commented on GitHub (Jul 16, 2022):

You need to provide this as environment variables not parameters to the binary. And please make sure you are using latest code from git because this code is fresh and not included in any release yet.

<!-- gh-comment-id:1186119660 --> @decke commented on GitHub (Jul 16, 2022): You need to provide this as environment variables not parameters to the binary. And please make sure you are using latest code from git because this code is fresh and not included in any release yet.
Author
Owner

@decke commented on GitHub (Jul 16, 2022):

I don't quite get the question you are asking if it works in docker and kubernetes environment. Do you need it on a shell or shell script?

<!-- gh-comment-id:1186121195 --> @decke commented on GitHub (Jul 16, 2022): I don't quite get the question you are asking if it works in docker and kubernetes environment. Do you need it on a shell or shell script?
Author
Owner

@decke commented on GitHub (Jul 16, 2022):

If you want to do this in a shell it needs to look like:
SMTPRELAY_LOGFILE="/var/log/smtprelay.log" SMTPRELAY_LISTEN="starttls://127.0.0.1:587" /usr/local/bin/smtprelay

<!-- gh-comment-id:1186122025 --> @decke commented on GitHub (Jul 16, 2022): If you want to do this in a shell it needs to look like: `SMTPRELAY_LOGFILE="/var/log/smtprelay.log" SMTPRELAY_LISTEN="starttls://127.0.0.1:587" /usr/local/bin/smtprelay`
Author
Owner

@HakunMatat4 commented on GitHub (Jul 19, 2022):

You need to provide this as environment variables not parameters to the binary. And please make sure you are using latest code from git because this code is fresh and not included in any release yet.

That makes sense now, I have been using smtprelay v1.8.0 from May
My issue was to get it to accept environment and not the file but the above explains now what is wrong.

Even so it is not released yet, it would be nice to have the main page updated with it and example.
My silly mistake I guess was downloading smartreply.ini from the main page which is updated and then using the latest release which does not support environment vars.

I will look into how to compile the latest code as you recommended.
So far I have been using the smtprelay-v1.8.0-linux-amd64.tar.gz and got it working with docker and kubernetes as I mentioned, and literally few minutes ago I got it working with the secure e-mail Proton.
That is freaking awesome since everybody uses Postfix with a lot of changes here and there, smtprelay does it like a charm with 4 lines.
Time to spread the word :)

Thanks a lot for the reply

<!-- gh-comment-id:1188583326 --> @HakunMatat4 commented on GitHub (Jul 19, 2022): > You need to provide this as environment variables not parameters to the binary. And please make sure you are using latest code from git because this code is fresh and not included in any release yet. That makes sense now, I have been using smtprelay v1.8.0 from May My issue was to get it to accept environment and not the file but the above explains now what is wrong. Even so it is not released yet, it would be nice to have the main page updated with it and example. My silly mistake I guess was downloading `smartreply.ini ` from the main page which is updated and then using the latest release which does not support environment vars. I will look into how to compile the latest code as you recommended. So far I have been using the smtprelay-v1.8.0-linux-amd64.tar.gz and got it working with docker and kubernetes as I mentioned, and literally few minutes ago I got it working with the secure e-mail Proton. That is freaking awesome since everybody uses Postfix with a lot of changes here and there, smtprelay does it like a charm with 4 lines. Time to spread the word :) Thanks a lot for the reply
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/smtprelay#17
No description provided.