-
Notifications
You must be signed in to change notification settings - Fork 96
Auto Add Labels To New Messages
Gaute Hope edited this page Sep 29, 2015
·
4 revisions
You can use the before-add-message.rb
hook to add labels to messages as they
arrive.
before-add-message
------------------
File: ~/.sup/hooks/before-add-message.rb
Executes immediately before a message is added to the index.
Variables:
message: the new message
if message.from.email.start_with? 'bill.gates@microsoft'
message.add_label :microsoft
end
if message.recipients.any? { |person| person.email =~ /admin-.*@example.org/i }
message.add_label :admin
end
if message.recipients.any? { |person| person.email =~ /admin-.*@example.org/i }
message.remove_label :inbox
message.add_label :admin
end
subj = message.subj.downcase
if subj.start_with? '[sup-talk'
message.add_label :sup
end
if message.raw_header.include? "SpamScore:.*sssss"
message.add_label :spam
log "Marking message #{message.id} as spam, subject is '#{message.subj}'"
end