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

Environment variable for amavis subject tag #596

Merged
merged 4 commits into from
Jun 23, 2017
Merged

Environment variable for amavis subject tag #596

merged 4 commits into from
Jun 23, 2017

Conversation

elbracht
Copy link
Contributor

@elbracht elbracht commented May 8, 2017

Ref: #589

Environment variable to change the amavis tag sa_spam_subject_tag outside the container .

@tomav
Copy link
Contributor

tomav commented May 9, 2017

Hi @elbracht, don't forget integration tests.

@elbracht elbracht changed the title WIP: Environment variable for amavis subject tag Environment variable for amavis subject tag May 9, 2017
@elbracht
Copy link
Contributor Author

@tomav do you have an idea why I can’t use a string as environment variable? If I use a number as environment variable in Makefile it works.

Works:

-e SA_SPAM_SUBJECT=10.0 \

Don’t work:

-e SA_SPAM_SUBJECT="SPAM: " \

@tomav
Copy link
Contributor

tomav commented May 15, 2017

Still 2 errors in this build. How can we move forward?

@elbracht
Copy link
Contributor Author

@tomav I can’t use a string as environment variable to update the $sa_spam_subject_tag in start-mailserver.sh. With a number or a fixed value as environment variable it works.

number (Makefile):

docker run -d --name mail \
...
-e SA_SPAM_SUBJECT=10.0 \

fixed value (start-mailserver.sh):

sed -i -r 's/^\$sa_spam_subject_tag (.*);/\$sa_spam_subject_tag = fixed value';/g' /etc/amavis/conf.d/20-debian_defaults

@tomav
Copy link
Contributor

tomav commented Jun 13, 2017

The error is here

@elbracht
Copy link
Contributor Author

@tomav I know that the test failed on this line but this is not the problem.

I think the problem is that the environment variable is not passed to the start script start-mailserver.sh (here).

Or the script doesn't write the variable to the config file (here).

@tomav
Copy link
Contributor

tomav commented Jun 23, 2017

I have an error with sed when trying to run the line for subject tag configuration.
This seems to work better:

sed -i -r 's/^\$sa_spam_subject_tag (.*);/\$sa_spam_subject_tag = '"'$SA_SPAM_SUBJECT'"';/g'

Let me know if it works for you.

@elbracht
Copy link
Contributor Author

@tomav Nice! 👍

Now the local tests have been passed.

@tomav tomav merged commit 5a86193 into docker-mailserver:master Jun 23, 2017
@tomav
Copy link
Contributor

tomav commented Jun 23, 2017

Here we are!

@elbracht elbracht deleted the amavis-spam-subject-tag branch June 23, 2017 20:45
@jholster
Copy link

jholster commented Jan 18, 2019

It's not clear for me how to disable the subject rewrite entirely. If SA_SPAM_SUBJECT is empty/undefined, it seems to default to ***SPAM***. I would like to keep my subject unchanged, because I'm moving spams to separate folder.

@johansmitsnl
Copy link
Contributor

@jholster maybe add a " " space in the variable might fit your needs.

@jholster
Copy link

jholster commented Feb 8, 2019

@johansmitsnl Tried that, didn't help, maybe the configuration parsers trims the lines? Anyway, sounds like hack. Can we additionally have SA_ENABLE_SPAM_SUBJECT_REWRITE boolean variable?

I think it's very common case to move spam messages into separate spam folder. Once in a while I skim through my spams and move false positives to inbox/archive folder (to teach SpamAssassin). But the moved messages will have "SPAM" in subject line forever, which is kind of ugly.

@elbracht
Copy link
Contributor Author

@jholster The following environment variable should solve your problem:

-e SA_SPAM_SUBJECT=undef

@jholster
Copy link

jholster commented Feb 16, 2019

@elbracht Thanks, that finally solved the issue. If anyone else wonders how the .env parser distinguish between undef(ined) and "undef" – it does not, "undef" is just a magic string, see here.

RichardFevrier pushed a commit to RichardFevrier/docker-mailserver that referenced this pull request Aug 26, 2019
* Environment variable for spam subject tag
* Add SA_SPAM_SUBJECT to readme
* Add integration tests for spam subject tag
* Fix overwrite environment variable in config file
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

Successfully merging this pull request may close these issues.

None yet

4 participants