EmailDiscussions.com  

Go Back   EmailDiscussions.com > Email Service Provider-specific Forums > FastMail Forum
Register FAQ Members List Calendar Today's Posts
Stay in touch wirelessly

FastMail Forum All posts relating to FastMail.FM should go here: suggestions, comments, requests for help, complaints, technical issues etc.

Reply
 
Thread Tools
Old 15 Jan 2015, 12:01 PM   #1
IanO
Senior Member
 
Join Date: Oct 2003
Posts: 102
How to use Sieve to detect an empty To address

This doesn't work:

Code:
if header :is ["To"] [""]
{
... do something
}
I want to file emails from someone who frequently BCCs me frequently (and so there is no To address), but if I receive a message directly to me I want to keep the message.
IanO is offline   Reply With Quote

Old 15 Jan 2015, 01:49 PM   #2
BritTim
The "e" in e-mail
 
Join Date: May 2003
Location: mostly in Thailand
Posts: 3,092
Code:
if not exists "to" 
{
    whatever
}
BritTim is offline   Reply With Quote
Old 17 Jan 2015, 03:32 AM   #3
IanO
Senior Member
 
Join Date: Oct 2003
Posts: 102
Thanks, I learned a new Sieve keyword.
IanO is offline   Reply With Quote
Old 17 Jan 2015, 11:16 AM   #4
n5bb
Intergalactic Postmaster
 
Join Date: May 2004
Location: Irving, Texas
Posts: 8,927
Arrow A more complex alternative

That rule will correctly find messages which don't contain a To header, and it it works for you it's the best since it is so simple. But remember that this doesn't mean that the messages it catches always come from that specific person sending BCC messages to you.
  • If this specific sender includes a To field which does not include you (but does include others) and places your address in Cc or Bcc, you will receive the message but this rule won't be triggered.
  • If any sender (not necessarily this specific sender) leaves the To field empty and includes your address in Cc or Bcc, this rule will be triggered.
It's hard to catch all possible cases, but if you only wanted to catch messages sent by this specific sender which were missing a To header, you could instead use the following:
Code:
if allof (
header :contains "from" ["sender1@xx","sender2@xx"],
not header :contains ["to", "cc"] ["youradr1@xx","youradr2@xx"]
)
{ whatever }
This rule will catch only messages from a list of From addresses where any of your possible addresses are not contained in To or Cc (so your address must be in Bcc). It doesn't require To to be empty, so it will catch messages sent to others where you are added via Bcc. The address lists could contain a single address (so that the brackets are not needed) or contain any number of addresses, such as:
Code:
"sender@xx"
["sender1@xx","sender2@yy","sender3@zz"]
Bill
n5bb is offline   Reply With Quote
Old 18 Jan 2015, 06:34 AM   #5
IanO
Senior Member
 
Join Date: Oct 2003
Posts: 102
I am using something like this:

Code:
if allof (not exists ["To"], header :contains ["From"] ["someoneOrOther"])
	{ <file away silently>; }
else
	{ <file somewhere I will notice>; }
But you are right I could replace the exists part with not header :contains "To" "myAddress".

While I am asking sieve questions, I am using Notepad++ and saving it as a C file; this works OK for comments, strings, and matching brackets, but it's not so good for keywords. Notepad++ is a nice editor but there is no plugin for Sieve. It is also possible to customize it with keywords, but I have not done that and I wasn't able to find anyone else who had either.

Does anyone have a Sieve editor suggestion?
IanO is offline   Reply With Quote
Old 18 Jan 2015, 09:12 AM   #6
BritTim
The "e" in e-mail
 
Join Date: May 2003
Location: mostly in Thailand
Posts: 3,092
Quote:
Originally Posted by IanO View Post
Does anyone have a Sieve editor suggestion?
Not really. There is an old sieve syntax file for vim available at https://github.com/vim-scripts/sieve.vim, but I personally would not want to do much work these days in vim. Also, as I recall, it only syntax highlights core sieve keywords. It has no support for the many extensions used these days.

My code editor of choice is Komodo (based on Scintilla). It would be pretty easy to add sieve syntax support, but I have never bothered.
BritTim is offline   Reply With Quote
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +9. The time now is 05:16 AM.

 

Copyright EmailDiscussions.com 1998-2022. All Rights Reserved. Privacy Policy