Hi !
Can you help me please with sieve plugin for dovecot
I have this rule:
/require ["variables", "envelope", "fileinto", "subaddress", "imap4flags"]; if anyof ( address :is [ "to", "cc", "bcc" ] "test@example.com", envelope :contains "to" "test@example.com"
)
{
fileinto "Test";
stop;
}/
and if somebody sends me an email with "test@example.com" in "TO" or "CC" - then sieve works properly and put this email in Test folder, but i can't understand why if it sends e-mail to "test@example.com" in BCC - sieve don't move it to Test but leave it in Inbox?
If i run sieve-test -faD .dovecot.sieve "Message-ID" i get:
/Performed actions:
- store message in folder: Test
Implicit keep:
(none)
sieve-test(root): Info: final result: success/
but in dovecot log i get: /Info: sieve: msgid=<20130421074437.570EA2BA1C1F@mail.com>: stored mail into mailbox 'INBOX'/ and email is going to Inbox folder, instead Test.
Please tell me what i am doing wrong and how i can make sieve to work properly with BCC.
Thank You.
-- View this message in context: http://dovecot.2317879.n4.nabble.com/Sieve-BCC-tp41757.html Sent from the Dovecot mailing list archive at Nabble.com.
At 12AM -0700 on 21/04/13 you (iliusha) wrote:
Can you help me please with sieve plugin for dovecot
I have this rule:
/require ["variables", "envelope", "fileinto", "subaddress", "imap4flags"]; if anyof ( address :is [ "to", "cc", "bcc" ] "test@example.com", envelope :contains "to" "test@example.com"
) { fileinto "Test"; stop;
}/
and if somebody sends me an email with "test@example.com" in "TO" or "CC" - then sieve works properly and put this email in Test folder, but i can't understand why if it sends e-mail to "test@example.com" in BCC - sieve don't move it to Test but leave it in Inbox?
You can't. The whole point of Bcc is that the sending SMTP server removes the header before the mail is sent, so that the other recipients can't see someone was CCed.
Filtering on the envelope recipient address ought to be sufficient, unless that address is getting rewritten somewhere in the mail path.
If i run sieve-test -faD .dovecot.sieve "Message-ID" i get:
/Performed actions:
- store message in folder: Test
Implicit keep:
(none)
sieve-test(root): Info: final result: success/
but in dovecot log i get: /Info: sieve: msgid=<20130421074437.570EA2BA1C1F@mail.com>: stored mail into mailbox 'INBOX'/ and email is going to Inbox folder, instead Test.
I'm not sure exactly what you're doing here, but if you're passing sieve-test a mail that does actually have a Bcc line with your address in, I would expect it to work. The problem is that ordinary incoming mail won't have that line.
Ben
The whole point of Bcc is that the sending SMTP server removes the header before the mail is sent Yes, you right, thank you, i didn't know that.
but, do you now what is strange - ok i don't have the BCC point in message header, but i have Envelope-to: header, why the sieve won't process it? (envelope :contains "to" "test@example.com" )
This is how i receive email headers:
/Return-path: <sender@example.com> *Envelope-to: test@example.com* Delivery-date: Sun, 21 Apr 2013 09:24:23 +0300 Received: from [1.1.1.1] (helo=helo) by MX-Server with esmtp (Exim 4.77 (FreeBSD)) (envelope-from <sender@example.com>) id 1UTnhH-000Gx0-I2 *for test@example.com*; Sun, 21 Apr 2013 09:24:23 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=example.com; s=dkim; h=Content-Type:MIME-Version:Message-ID:Date:Subject:To:From; bh=JPnc/R6ltRQ3Naw1NgX7zO/kXeb6z96fjMSgEkiwbRk=; b=aXNcToLUBFCJJDs8zTCKPIHHIaKQCQYwGC0/mKKsPA4sqXtca7Y1jsqSdO86WolrQV9J/LWmvT39PufdvQjo0u9zmRWfGOBDi2NJ9m+6KS5cQhQgDyVkNr+HbpX/pm1ALkzGfRWMDFbVzEZ+IDCB /TWHE2A9+yCZIQGlLOIDTuo=; Received: from [1.1.1.1] (helo=AdminPC) by mx0.example.com with esmtpa (Exim 4.80.1 (FreeBSD)) (envelope-from <sender@example.com>) id 1UTkt0-00011o-1U; Sun, 21 Apr 2013 06:24:22 +0300 From: "Admin" <sender@example.com> To: <example.com@gmail.com> Subject: test1 Date: Sun, 21 Apr 2013 09:24:23 +0300 Message-ID: <000001ce3e58$ddc6a3b0$9953eb10$@example.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0001_01CE3E72.031429D0" X-Mailer: Microsoft Outlook 14.0 Thread-Index: Ac4+WN2excy0RNupTa6JtRtSdrQjog== Content-Language: ro X-ACL-Warn: M40=White Host or Relay Host X-SA-Exim-Connect-IP: 1.1.1.1 X-SA-Exim-Mail-From: sender@example.com X-SA-Exim-Scanned: No (on mx0.example.com); SAEximRunCond expanded to false
This is a multipart message in MIME format.
------=_NextPart_000_0001_01CE3E72.031429D0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit
test/
-- View this message in context: http://dovecot.2317879.n4.nabble.com/Sieve-BCC-tp41757p41759.html Sent from the Dovecot mailing list archive at Nabble.com.
Am 21.04.2013 15:10, schrieb iliusha:
The whole point of Bcc is that the sending SMTP server removes the header before the mail is sent Yes, you right, thank you, i didn't know that.
but, do you now what is strange - ok i don't have the BCC point in message header, but i have Envelope-to: header, why the sieve won't process it? (envelope :contains "to" "test@example.com" )
uhm the header is "Envelope-to" and you write "envelope :contains"
This is how i receive email headers:
/Return-path: <sender@example.com> *Envelope-to: test@example.com*
if header :matches ["Envelope-to"] ["test@example.com"] {} would make more sense
*if header :matches ["Envelope-to"] ["test@examle.com"] {} *
is exactly what i need. Thank You All.
-- View this message in context: http://dovecot.2317879.n4.nabble.com/Sieve-BCC-tp41757p41761.html Sent from the Dovecot mailing list archive at Nabble.com.
Hi Reindl,
On 4/21/2013 3:21 PM, Reindl Harald wrote:
Am 21.04.2013 15:10, schrieb iliusha:
but, do you now what is strange - ok i don't have the BCC point in message header, but i have Envelope-to: header, why the sieve won't process it? (envelope :contains "to" "test@example.com" ) uhm the header is "Envelope-to" and you write "envelope :contains"
This is how i receive email headers:
/Return-path: <sender@example.com> *Envelope-to: test@example.com* if header :matches ["Envelope-to"] ["test@example.com"] {} would make more sense
Although the above will work, it does not mean that the approach Iliusha has chosen is wrong. Be sure you know the Sieve specification before you comment:
https://tools.ietf.org/html/rfc5228#section-5.4
In fact, that is normally the cleanest method to access the actual message envelope. Depending on the setup, those envelope headers may or may not represent the correct information. They usually do, if they exist, but still.
Also, why do you use ':matches' in your example? :)
Regards,
Stephan.
Am 21.04.2013 15:38, schrieb Stephan Bosch:
/Return-path: <sender@example.com> *Envelope-to: test@example.com* if header :matches ["Envelope-to"] ["test@example.com"] {} would make more sense
Although the above will work, it does not mean that the approach Iliusha has chosen is wrong. Be sure you know the Sieve specification before you comment:
i comment not based on how things SHOULD be in theory i GENERALLY comment with working examples how they ARE from the real world
In fact, that is normally the cleanest method to access the actual message envelope. Depending on the setup, those envelope headers may or may not represent the correct information. They usually do, if they exist, but still.
Also, why do you use ':matches' in your example? :)
because the "contains" from the OP has the same intention?
because it is from a well working sieve-script for subject-matching with some hundret entries to protect postmaster-address from most spam while go with the RFC that postmaster must not be spam-filtered at the MX
if header :matches ["Subject"] ["*please your woman*","*see sexy*"]{discard;}
goes well with the RFC as example and leaves me in peace at the same time :-)
On 4/21/2013 3:55 PM, Reindl Harald wrote:
Am 21.04.2013 15:38, schrieb Stephan Bosch:
/Return-path: <sender@example.com> *Envelope-to: test@example.com* if header :matches ["Envelope-to"] ["test@example.com"] {} would make more sense Although the above will work, it does not mean that the approach Iliusha has chosen is wrong. Be sure you know the Sieve specification before you comment:
https://tools.ietf.org/html/rfc5228#section-5.4 i comment not based on how things SHOULD be in theory i GENERALLY comment with working examples how they ARE from the real world
I don't have a problem with that. I'm just saying that it DOES make (more) sense to use the envelope extension the way he is doing. :)
Did you encounter any problems with the envelope extension in your own experience?
Also, why do you use ':matches' in your example? :) because the "contains" from the OP has the same intention?
because it is from a well working sieve-script for subject-matching with some hundret entries to protect postmaster-address from most spam while go with the RFC that postmaster must not be spam-filtered at the MX
if header :matches ["Subject"] ["*please your woman*","*see sexy*"]{discard;}
goes well with the RFC as example and leaves me in peace at the same time :-)
Well, using ':matches" for one key value without wildcards is a bit useless. In that case it is equivalent to ':is' or leaving the match type out. But yes, I agree, if it is part of a large list of match keys (only some of which have no wild cards), it does make sense.
Regards,
Stephan.
Am 21.04.2013 16:16, schrieb Stephan Bosch:
On 4/21/2013 3:55 PM, Reindl Harald wrote:
i comment not based on how things SHOULD be in theory i GENERALLY comment with working examples how they ARE from the real world
I don't have a problem with that. I'm just saying that it DOES make (more) sense to use the envelope extension the way he is doing. :)
Did you encounter any problems with the envelope extension in your own experience?
i try to minimize the usage of extensions to write as portable scripts as possible independent if we speak about sieve, php or whatever language
Also, why do you use ':matches' in your example? :) because the "contains" from the OP has the same intention?
because it is from a well working sieve-script for subject-matching with some hundret entries to protect postmaster-address from most spam while go with the RFC that postmaster must not be spam-filtered at the MX
if header :matches ["Subject"] ["*please your woman*","*see sexy*"]{discard;}
goes well with the RFC as example and leaves me in peace at the same time :-)
Well, using ':matches" for one key value without wildcards is a bit useless. In that case it is equivalent to ':is' or leaving the match type out. But yes, I agree, if it is part of a large list of match keys (only some of which have no wild cards), it does make sense
yep, and the spamfilter-sieve is generated from a database with a small webinterface for add and remove entries and the only difference is the decision komma at the end or not - see below, maybe some other admin is happy with it :-)
if header :matches ["Subject"] [ "*aktuelle stellenausschreibungen*", "*alert - new message received*", "*alert will be released in just*", "*arbeitsmarkt naturwissenschaften*", "*armbanduhren*", "*banks and wallstreet*", "*banks manipulate us*", "*bedroom life*", "*can earn more*", "*can we chat*", "*card payment*", "*company to research*", "*consultant*", "*control de presentismo*", "*could be a big bounce play*", "*day-trade play*", "*delight this night*", "*einen neuen job*", "*environmental company*", "*featured on cbs*", "*financial consulting*", "*fw: job", "*fw: reseume*", "*gibraltar*", "*got those pics*", "*great opportunity*", "*great start with actual gains*", "*hour work week*", "*investment partnership*", "*invite you to work*", "*job offer*", "*konto bei credit suisse*", "*kraft foods*", "*love life*", "*make money today*", "*making a fool of you*", "*methods of power*", "*my profile*", "*new daily matches*", "*new ematches by email*", "*new monster stock*", "*offenen stellen*", "*organic growth potential*", "*payment new code*", "*per hour for remote assistance*", "*please your woman*", "*promocione*", "*promotion company looking*", "*re: my profile*", "*re: reseume*", "*ready to flirt*", "*remote assistants*", "*satisfy ladies*", "*searching for representatives*", "*see sexy*", "*the big dollars*", "*ticket to richer life*", "*ubs ag -konto*", "*ubs ag-konto*", "*united technologies corporation*", "*viagra*", "*viarga*", "*von ihrem konto bei ubs ag*", "*wake up her true desires*", "*we are currently looking to recruit", "*we are looking for assistants in your town*", "*we invite you to a remote job*", "*we offer you a personal decision*", "*we will advise you for free*", "*wir suchen einen operationsmanager*", "*wire transfer confirmation*", "*with the advertising*", "*work offer*", "*you have new matches*", "*your carnal needs*", "*your girlfriend*", "*your interest rates are unfair*", "*your intimate life*", "*your monthly income can be increased*", "*your wire transfer*", "2 explosions*", "30 days to a new ph*", "a call for nomination*", "abwesend: spam quarantine*", "achtung: von ihrem konto*", "act now and thank me later*", "add the title*", "administrative assistant*", "administrative sales*", "administrator", "administrator in*", "administrator pos*", "administrator-financier*", "alert - new matches", "angebote im netz", "arbeit in deutschland*", "arbeiten in teilzeit*", "are you ready to impress*", "as a matter*", "assistant vacancy*", "bases de empresas*", "bekommen sie philip stein*", "best prices*", "breaking -*", "buy today*", "career opportunity*", "congrats members*", "conspiracy: banks*", "control de accesos*", "current open position*", "current vacancy*", "database management*", "do you desire*", "do you want to gratify*", "employment*", "environmental business*", "environmental organization*", "es ist der magische*", "excellent opportunity*", "fantastische ergebnisse*", "finance administrator*", "finance manager", "financial redemption*", "from coast to coast", "from the desk of*", "full recruitment*", "fw: work*", "get a new job*", "getting ready*", "hey honey*", "hey there*", "hi honey*", "hi sweetie*", "hot stock*", "i seek for your sincere*", "information zur jobborse*", "it continues to climb*", "it is absolutely awesome*", "it reports additional positive results", "it`s me again*", "job ad*", "job angebot*", "job offer*", "job opportunity*", "job proposal*", "job-vorschlag*", "jobbvagledare*", "karriarcenter*", "keep your gf*", "learn*", "life is miserable*", "linkedin*", "listados de*", "located in europe?*", "managed to make*", "manager*", "more exposure", "most good recruiters", "my hot pics*", "my pics for you", "new buddy request*", "new job*", "new request", "new shop*", "next day delivery. sale", "offene stelle*", "offshore*", "open vacancy*", "order now*", "order today*", "our quickly expanding*", "paid surveys*", "part-time work*", "position opening*", "postmaster order on www.gsm-proslushka.com", "postmaster*", "re: changelog new", "re: jobbsokande*", "re: remember me*", "re: spam quarantine summary*", "re: urgent notification*", "re: your profile", "read me*", "read, research*", "recruitment*", "retirement out of office re: spam quarantine summary*", "save money*", "should you buy it*", "show your true greatness*", "small cap daily", "small helper for*", "soka job*", "something big is coming*", "spy devices*", "start new employment today*", "start working today*", "starten sie*", "stunning investigation*", "submit your nomination*", "superb chance for employment*", "sweet lord*", "texas explosion*", "this company*", "this stock*", "today new matches", "turn your 2 spare*", "ubs ag kontobenachrichtigung*", "ultra fast delivery*", "vacancy*", "verizon wireless*", "virtual assistant*", "virtual manager*", "virtuelle-manager*", "we are creating*", "we are hearing some big*", "we grow thin quickly*", "we invite you*", "what a mega*", "work at*", "work for*", "work with*", "working in europe", "working in*", "working part time*", "working with*", "you are nominated*", "you can earn an additional*", "you do not have much money*", "you have new matches", "your tracking number*" ] { discard; } else { keep; }
On 4/21/2013 3:10 PM, iliusha wrote:
The whole point of Bcc is that the sending SMTP server removes the header before the mail is sent Yes, you right, thank you, i didn't know that.
but, do you now what is strange - ok i don't have the BCC point in message header, but i have Envelope-to: header, why the sieve won't process it? (envelope :contains "to" "test@example.com" )
This is how i receive email headers:
/Return-path: <sender@example.com> *Envelope-to: test@example.com* Delivery-date: Sun, 21 Apr 2013 09:24:23 +0300
That is strange. This could mean that the envelope is passed a bit differently than you think. Those headers are only used by Dovecot if no other sources are available for envelope information.
Do you see anything strange in the logs?
You could try the following Sieve script to get a bit more information (perhaps I should make a normal debug log line for this).
require "vnd.dovecot.debug"; require "envelope"; require "variables";
# Get envelope if envelope :matches "to" "*" { set "env_to" "${1}"; }
debug_log "ENVELOPE_TO: ${env_to}";
You need to enable the vnd.dovecot.debug extension in your sieve_extensions= setting.
The debug line will be logged in the user log (e.g. ~/.dovecot.sieve.log)
Regards,
Stephan.
Stephan Bosch-2 wrote
On 4/21/2013 3:10 PM, iliusha wrote:
The whole point of Bcc is that the sending SMTP server removes the header before the mail is sent
Do you see anything strange in the logs?
You could try the following Sieve script to get a bit more information (perhaps I should make a normal debug log line for this).
require "vnd.dovecot.debug"; require "envelope"; require "variables";
# Get envelope if envelope :matches "to" "*" { set "env_to" "${1}"; }
debug_log "ENVELOPE_TO: ${env_to}";
You need to enable the vnd.dovecot.debug extension in your sieve_extensions= setting.
The debug line will be logged in the user log (e.g. ~/.dovecot.sieve.log)
Regards,
Stephan.
Enabling debug i found where was my mistake, so i use Virtual list: test@example.com -> user@example.com. and when i sent email to test@example.com it automatically goes to user@example.com, but in email headers i saw Envelope To: test@example.com, and I thought that sieve also sees Envelope to: test@example.com, but it is not right. (It is my first experience with sieve, i am new in this.)
main_script: line 17: info: DEBUG: ENVELOPE_TO: *user@example.com*. info: msgid=<010301ce3e9e$642ed9f0$2c8c8dd0$@gmail.com>: stored mail into mailbox 'INBOX'
Anyway, i'm happy that i found the solution using this forum, otherwise i did not believe that it is possible. Thank You.
-- View this message in context: http://dovecot.2317879.n4.nabble.com/Sieve-BCC-tp41757p41767.html Sent from the Dovecot mailing list archive at Nabble.com.
participants (4)
-
Ben Morrow
-
iliusha
-
Reindl Harald
-
Stephan Bosch