module MultiMail
@note The multimap gem was yanked, so we re-implement its functionality. @see github.com/josh/multimap
Constants
- VERSION
Attributes
autoresponse_pattern[RW]
@return [RegExp] a message whose subject matches this pattern will be
considered an autoresponse
Public Class Methods
autoresponse?(message)
click to toggle source
Returns whether a message is an autoresponse.
@param [Mail::Message] message a message @return [Boolean] whether a message is an autoresponse @see github.com/jpmckinney/multi_mail/wiki/Detecting-autoresponders
# File lib/multi_mail.rb, line 65 def autoresponse?(message) !!( # If any of the following headers are present and have the given value. { 'Delivered-To' => 'Autoresponder', 'Precedence' => 'auto_reply', 'Return-Path' => nil, # in most cases, this would signify a bounce 'X-Autoreply' => 'yes', 'X-FC-MachineGenerated' => 'true', 'X-POST-MessageClass' => '9; Autoresponder', 'X-Precedence' => 'auto_reply', }.find do |name,value| message[name] && message[name].decoded == value end || # If any of the following headers are present. [ 'X-Autogenerated', # value is one of Forward, Group, Letter, Mirror, Redirect or Reply 'X-AutoReply-From', # value is an email address 'X-Autorespond', # value is an email subject 'X-Mail-Autoreply', # value is often "dtc-autoreply" but can be another tag ].any? do |name| message[name] end || # If the Auto-Submitted header is present and is not equal to "no". ( message['Auto-Submitted'] && message['Auto-Submitted'].decoded != 'no' ) || # If the message subject matches the autoresponse pattern. ( MultiMail.autoresponse_pattern && message.subject && message.subject[MultiMail.autoresponse_pattern] ) ) end
setup() { |self| ... }
click to toggle source
Configures MultiMail
.
-
`autoresponse_pattern`: a message whose subject matches this pattern will be considered an autoresponse
@example
require 'multi_mail' MultiMail.setup do |config| config.autoresponse_pattern = /^Out of Office AutoReply:/i end
# File lib/multi_mail.rb, line 56 def setup yield self end