Class: MailDiode::BlacklistFilter
- Defined in:
- lib/maildiode-plugins/blacklist.rb
Instance Method Summary collapse
- #helo(helo) ⇒ Object
-
#initialize(settings) ⇒ BlacklistFilter
constructor
A new instance of BlacklistFilter.
- #load_settings(settings) ⇒ Object
- #mail(from) ⇒ Object
- #rcpt(recipient) ⇒ Object
Methods inherited from Filter
Constructor Details
#initialize(settings) ⇒ BlacklistFilter
Returns a new instance of BlacklistFilter.
18 19 20 21 |
# File 'lib/maildiode-plugins/blacklist.rb', line 18 def initialize(settings) @blacklisted_recipients = [] load_settings(settings) end |
Instance Method Details
#helo(helo) ⇒ Object
23 24 |
# File 'lib/maildiode-plugins/blacklist.rb', line 23 def helo(helo) end |
#load_settings(settings) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/maildiode-plugins/blacklist.rb', line 38 def load_settings(settings) settings.get_settings('blacklist').each do | setting | key = setting.key value = setting.value case key when 'to' @blacklisted_recipients << value MailDiode::log_debug " #{key} X #{value}" else MailDiode::log_warning "Blacklist ignoring unknown: #{key}" end end end |
#mail(from) ⇒ Object
26 27 |
# File 'lib/maildiode-plugins/blacklist.rb', line 26 def mail(from) end |
#rcpt(recipient) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/maildiode-plugins/blacklist.rb', line 29 def rcpt(recipient) @blacklisted_recipients.each do | pattern | re = Regexp.new(pattern, Regexp::IGNORECASE) if(recipient.match(re)) raise MailDiode::SMTPError.new(MailDiode::SMTPError::TOO_MANY_REJECTS + ": " + recipient) end end end |