Correct way to make multi-part message filters using the DH API


#1

Suppose I want to add the following filter to mail@mydomain.com:

When an email:
From Contains "one@one.com"
From Contains "two@two.com"
From Contains "three@three.com"
From Contains "four@four.com"
(Match any of the above)
Do this:
Delete it.
Execute and continue

What’s the right way to do this via the Mail API? The Wiki says “To create a complex multi-part filter, simply append an underscore to each of the above, followed by a number (starting at 1) for which step of the filter it is.” However, everything I’ve tried gives errors :frowning:


#2

Sorry for the confusion! The only part that should need to be numbered is the part with multiple parts, so just filter_on. Everything else is the same as mentioned in the wiki. If this doesn’t work, please let us know and provide the specific error. :slight_smile:


#3

Ehh, still getting errors. With the following input (placeholder address):

address = mail@mydomain.com
rank = 0
filter = one@one.com
filter_on = subject
action = delete
contains = yes
stop = yes
filter_1 = two@two.com
filter_on_1 = subject
action_1 = or
filter_2 = three@three.com
filter_on_2 = subject
action_2 = or

…which results in the command:
cmd=mail-add_filter&address=mail@mydomain.com&rank=0&filter=one@one.com&filter_on=subject&action=delete&contains=yes&stop=yes&filter_1=two@two.com&filter_on_1=subject&action_1=or&filter_2=three@three.com&filter_on_2=subject&action_2=or

…the resultant error is:
error cannot_create_simple_and_complex_filter


#4

It may be the numbering that’s off, and also the types of filters you’ve set. If you’d like to filter for the subject, the filter_# line needs to = case sensitive words rather than an email address. If you’d like to filter for an email address, the filter_on_# line must = from, rather than subject. Please see these two examples below:

[quote]address = mail@mydomain.com
rank = 0
filter_1 = Case Sensitive Subject Line
filter_on_1 = subject
action_1 = delete
contains_1 = yes
stop_1 = yes
filter_2 = Case Sensitive Subject Line
filter_on_2 = subject
action_2 = or
filter_3 = Case Sensitive Subject Line
filter_on_3 = subject
action_3 = or[/quote]

[quote]address = mail@mydomain.com
rank = 0
filter_1 = one@one.com
filter_on_1 = from
action_1 = delete
contains_1 = yes
stop_1 = yes
filter_2 = two@two.com
filter_on_2 = from
action_2 = or
filter_3 = three@three.com
filter_on_3 = from
action_3 = or[/quote]

If it still isn’t working after you’ve made those changes, please try setting the filters via our web panel (which we still officially support, unlike the API) here: https://panel.dreamhost.com/index.cgi?tree=mail.filters&

And of course, if you have any questions, feel free to let me know! Thanks :slight_smile:


#5

And don’t forget that using message filters to create an announcement list doesn’t comply with the dreamhost anti-spam policy as I explained to you in this thread: https://discussion.dreamhost.com/thread-136926.html

For those that are playing along at home, he’s using the dreamhost API to circumvent the need for double opt-in on a mailing list xD


#6

[quote=“LakeRat, post:5, topic:59075”]using the dreamhost API to circumvent the need for double opt-in on a mailing list xD
[/quote] Haha not quite - it’s for a private lab. The whole point of using the DreamHost API was to avoid over-complicating the admin application. Instead of parsing the emails with PHP and re-sending them out or using an external application it’s simpler to just use your guys’ built-in stuff. The end result is the same, and nobody’s getting spammed.

Anyway, thank you very much for the help, DH_Elle S!


#7

You’re very welcome, Diogenes! Was it helpful at all? I’m happy to help, just let us know whenever you need us :slight_smile:


#8

So, just to be clear, are you abiding by the double opt-in requirement?


#9

Yes.


#10

thumbs up :smiley: