Module: MList::Util::TMailWriters

Included in:
TMailBuilder
Defined in:
lib/mlist/util/tmail_methods.rb

Instance Method Summary collapse

Instance Method Details

#bcc=(recipient_addresses) ⇒ Object



128
129
130
# File 'lib/mlist/util/tmail_methods.rb', line 128

def bcc=(recipient_addresses)
  tmail.bcc = sanitize_header(charset, 'bcc', recipient_addresses)
end

#charsetObject



90
91
92
# File 'lib/mlist/util/tmail_methods.rb', line 90

def charset
  'utf-8'
end

#delete_header(name) ⇒ Object



94
95
96
# File 'lib/mlist/util/tmail_methods.rb', line 94

def delete_header(name)
  tmail[name] = nil
end

#from=(from_address) ⇒ Object



132
133
134
# File 'lib/mlist/util/tmail_methods.rb', line 132

def from=(from_address)
  tmail.from = sanitize_header(charset, 'from', from_address)
end

#headers=(updates) ⇒ Object



98
99
100
101
102
103
104
105
106
# File 'lib/mlist/util/tmail_methods.rb', line 98

def headers=(updates)
  updates.each do |k,v|
    if TMail::Mail::ALLOW_MULTIPLE.include?(k.downcase)
      prepend_header(k,v)
    else
      write_header(k,v)
    end
  end
end

#in_reply_to=(*values) ⇒ Object



136
137
138
# File 'lib/mlist/util/tmail_methods.rb', line 136

def in_reply_to=(*values)
  tmail.in_reply_to = sanitize_header(charset, 'in-reply-to', *values)
end

#mailer=(value) ⇒ Object



140
141
142
# File 'lib/mlist/util/tmail_methods.rb', line 140

def mailer=(value)
  write_header('x-mailer', value)
end

#message_id=(value) ⇒ Object



144
145
146
# File 'lib/mlist/util/tmail_methods.rb', line 144

def message_id=(value)
  tmail.message_id = sanitize_header(charset, 'message-id', value)
end

#prepend_header(name, value) ⇒ Object

Add another value for the named header, it’s position being earlier in the email than those that are already present. This will raise an error if the header does not allow multiple values according to TMail::Mail::ALLOW_MULTIPLE.



113
114
115
116
117
118
# File 'lib/mlist/util/tmail_methods.rb', line 113

def prepend_header(name, value)
  original = tmail[name] || []
  tmail[name] = nil
  tmail[name] = sanitize_header(charset, name, value)
  tmail[name] = tmail[name] + original
end

#to=(recipient_addresses) ⇒ Object



124
125
126
# File 'lib/mlist/util/tmail_methods.rb', line 124

def to=(recipient_addresses)
  tmail.to = sanitize_header(charset, 'to', recipient_addresses)
end

#write_header(name, value) ⇒ Object



120
121
122
# File 'lib/mlist/util/tmail_methods.rb', line 120

def write_header(name, value)
  tmail[name] = sanitize_header(charset, name, value)
end