Postfix rewriting subject for specific addresses
I would like to add a tag to all email messages sent to a particular address. I have tried to copy examples from the web, but can't seem to get it working.
Here's what I've done so far:
Add to /etc/postfix/transport
email@example.com rewrite:
Add to /etc/postfix/master.cf
rewrite unix - - n - - smtp
-o header_checks=pcre:/etc/postfix/rewrite_headers
Create /etc/postfix/rewrite_headers containing
/^Subject: (.+)$/i REPLACE Subject: [Example tag] $1
If anyone can see where I am going wrong, please advise.
Thanks,
James
email postfix
add a comment |
I would like to add a tag to all email messages sent to a particular address. I have tried to copy examples from the web, but can't seem to get it working.
Here's what I've done so far:
Add to /etc/postfix/transport
email@example.com rewrite:
Add to /etc/postfix/master.cf
rewrite unix - - n - - smtp
-o header_checks=pcre:/etc/postfix/rewrite_headers
Create /etc/postfix/rewrite_headers containing
/^Subject: (.+)$/i REPLACE Subject: [Example tag] $1
If anyone can see where I am going wrong, please advise.
Thanks,
James
email postfix
add a comment |
I would like to add a tag to all email messages sent to a particular address. I have tried to copy examples from the web, but can't seem to get it working.
Here's what I've done so far:
Add to /etc/postfix/transport
email@example.com rewrite:
Add to /etc/postfix/master.cf
rewrite unix - - n - - smtp
-o header_checks=pcre:/etc/postfix/rewrite_headers
Create /etc/postfix/rewrite_headers containing
/^Subject: (.+)$/i REPLACE Subject: [Example tag] $1
If anyone can see where I am going wrong, please advise.
Thanks,
James
email postfix
I would like to add a tag to all email messages sent to a particular address. I have tried to copy examples from the web, but can't seem to get it working.
Here's what I've done so far:
Add to /etc/postfix/transport
email@example.com rewrite:
Add to /etc/postfix/master.cf
rewrite unix - - n - - smtp
-o header_checks=pcre:/etc/postfix/rewrite_headers
Create /etc/postfix/rewrite_headers containing
/^Subject: (.+)$/i REPLACE Subject: [Example tag] $1
If anyone can see where I am going wrong, please advise.
Thanks,
James
email postfix
email postfix
asked Dec 29 '15 at 17:52
James ShieldsJames Shields
14616
14616
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You should be able to do this without a custom transport, using built-in header checks.
Add to main.cf:
header_checks = pcre:/etc/postfix/rewrite_headers
Your rewrite_headers
file will have the existing rule wrapped in a conditional:
if /^To: email@example.com$/i
/^Subject: (.+)$/i REPLACE Subject: [Example tag] $1
endif
This should handle everything without the need for a transport config.
Is this also going to work if I want to change the sender of the mail for specific recipients?
– wie5Ooma
Jan 19 '18 at 22:46
Thanks for the tips. Unfortunately for me, my postfix config doesn't work as per documentation. header_checks doc says the header is checked in one bunch, not line by line. But this doesn't work accordingly to my config. So your tip doesn't work on my config.
– Luc-Olivier
May 25 '18 at 14:54
There was a mistake in my config example.header_checks
was set to a file path, but as it contains regex rules the path needs to be prefixed withpcre:
– Murphy's Prophet
Jun 9 '18 at 2:37
add a comment |
Unfortunately, the example above will not work as Postfix only works on one line at a time. The best I can tell, you will need a transport config.
New contributor
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
– Michael Homer
2 hours ago
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f252193%2fpostfix-rewriting-subject-for-specific-addresses%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You should be able to do this without a custom transport, using built-in header checks.
Add to main.cf:
header_checks = pcre:/etc/postfix/rewrite_headers
Your rewrite_headers
file will have the existing rule wrapped in a conditional:
if /^To: email@example.com$/i
/^Subject: (.+)$/i REPLACE Subject: [Example tag] $1
endif
This should handle everything without the need for a transport config.
Is this also going to work if I want to change the sender of the mail for specific recipients?
– wie5Ooma
Jan 19 '18 at 22:46
Thanks for the tips. Unfortunately for me, my postfix config doesn't work as per documentation. header_checks doc says the header is checked in one bunch, not line by line. But this doesn't work accordingly to my config. So your tip doesn't work on my config.
– Luc-Olivier
May 25 '18 at 14:54
There was a mistake in my config example.header_checks
was set to a file path, but as it contains regex rules the path needs to be prefixed withpcre:
– Murphy's Prophet
Jun 9 '18 at 2:37
add a comment |
You should be able to do this without a custom transport, using built-in header checks.
Add to main.cf:
header_checks = pcre:/etc/postfix/rewrite_headers
Your rewrite_headers
file will have the existing rule wrapped in a conditional:
if /^To: email@example.com$/i
/^Subject: (.+)$/i REPLACE Subject: [Example tag] $1
endif
This should handle everything without the need for a transport config.
Is this also going to work if I want to change the sender of the mail for specific recipients?
– wie5Ooma
Jan 19 '18 at 22:46
Thanks for the tips. Unfortunately for me, my postfix config doesn't work as per documentation. header_checks doc says the header is checked in one bunch, not line by line. But this doesn't work accordingly to my config. So your tip doesn't work on my config.
– Luc-Olivier
May 25 '18 at 14:54
There was a mistake in my config example.header_checks
was set to a file path, but as it contains regex rules the path needs to be prefixed withpcre:
– Murphy's Prophet
Jun 9 '18 at 2:37
add a comment |
You should be able to do this without a custom transport, using built-in header checks.
Add to main.cf:
header_checks = pcre:/etc/postfix/rewrite_headers
Your rewrite_headers
file will have the existing rule wrapped in a conditional:
if /^To: email@example.com$/i
/^Subject: (.+)$/i REPLACE Subject: [Example tag] $1
endif
This should handle everything without the need for a transport config.
You should be able to do this without a custom transport, using built-in header checks.
Add to main.cf:
header_checks = pcre:/etc/postfix/rewrite_headers
Your rewrite_headers
file will have the existing rule wrapped in a conditional:
if /^To: email@example.com$/i
/^Subject: (.+)$/i REPLACE Subject: [Example tag] $1
endif
This should handle everything without the need for a transport config.
edited Jun 9 '18 at 2:36
answered Jan 19 '18 at 22:14
Murphy's ProphetMurphy's Prophet
112
112
Is this also going to work if I want to change the sender of the mail for specific recipients?
– wie5Ooma
Jan 19 '18 at 22:46
Thanks for the tips. Unfortunately for me, my postfix config doesn't work as per documentation. header_checks doc says the header is checked in one bunch, not line by line. But this doesn't work accordingly to my config. So your tip doesn't work on my config.
– Luc-Olivier
May 25 '18 at 14:54
There was a mistake in my config example.header_checks
was set to a file path, but as it contains regex rules the path needs to be prefixed withpcre:
– Murphy's Prophet
Jun 9 '18 at 2:37
add a comment |
Is this also going to work if I want to change the sender of the mail for specific recipients?
– wie5Ooma
Jan 19 '18 at 22:46
Thanks for the tips. Unfortunately for me, my postfix config doesn't work as per documentation. header_checks doc says the header is checked in one bunch, not line by line. But this doesn't work accordingly to my config. So your tip doesn't work on my config.
– Luc-Olivier
May 25 '18 at 14:54
There was a mistake in my config example.header_checks
was set to a file path, but as it contains regex rules the path needs to be prefixed withpcre:
– Murphy's Prophet
Jun 9 '18 at 2:37
Is this also going to work if I want to change the sender of the mail for specific recipients?
– wie5Ooma
Jan 19 '18 at 22:46
Is this also going to work if I want to change the sender of the mail for specific recipients?
– wie5Ooma
Jan 19 '18 at 22:46
Thanks for the tips. Unfortunately for me, my postfix config doesn't work as per documentation. header_checks doc says the header is checked in one bunch, not line by line. But this doesn't work accordingly to my config. So your tip doesn't work on my config.
– Luc-Olivier
May 25 '18 at 14:54
Thanks for the tips. Unfortunately for me, my postfix config doesn't work as per documentation. header_checks doc says the header is checked in one bunch, not line by line. But this doesn't work accordingly to my config. So your tip doesn't work on my config.
– Luc-Olivier
May 25 '18 at 14:54
There was a mistake in my config example.
header_checks
was set to a file path, but as it contains regex rules the path needs to be prefixed with pcre:
– Murphy's Prophet
Jun 9 '18 at 2:37
There was a mistake in my config example.
header_checks
was set to a file path, but as it contains regex rules the path needs to be prefixed with pcre:
– Murphy's Prophet
Jun 9 '18 at 2:37
add a comment |
Unfortunately, the example above will not work as Postfix only works on one line at a time. The best I can tell, you will need a transport config.
New contributor
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
– Michael Homer
2 hours ago
add a comment |
Unfortunately, the example above will not work as Postfix only works on one line at a time. The best I can tell, you will need a transport config.
New contributor
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
– Michael Homer
2 hours ago
add a comment |
Unfortunately, the example above will not work as Postfix only works on one line at a time. The best I can tell, you will need a transport config.
New contributor
Unfortunately, the example above will not work as Postfix only works on one line at a time. The best I can tell, you will need a transport config.
New contributor
New contributor
answered 3 hours ago
SmugglerSmuggler
1
1
New contributor
New contributor
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
– Michael Homer
2 hours ago
add a comment |
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
– Michael Homer
2 hours ago
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
– Michael Homer
2 hours ago
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
– Michael Homer
2 hours ago
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f252193%2fpostfix-rewriting-subject-for-specific-addresses%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown