Module: MList::Util::TMailWriters
- Included in:
- TMailBuilder
- Defined in:
- lib/mlist/util/tmail_methods.rb
Instance Method Summary collapse
- #bcc=(recipient_addresses) ⇒ Object
- #charset ⇒ Object
- #delete_header(name) ⇒ Object
- #from=(from_address) ⇒ Object
- #headers=(updates) ⇒ Object
- #in_reply_to=(*values) ⇒ Object
- #mailer=(value) ⇒ Object
- #message_id=(value) ⇒ Object
-
#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.
- #to=(recipient_addresses) ⇒ Object
- #write_header(name, value) ⇒ Object
Instance Method Details
#bcc=(recipient_addresses) ⇒ Object
116 117 118 |
# File 'lib/mlist/util/tmail_methods.rb', line 116 def bcc=(recipient_addresses) tmail.bcc = sanitize_header(charset, 'bcc', recipient_addresses) end |
#charset ⇒ Object
78 79 80 |
# File 'lib/mlist/util/tmail_methods.rb', line 78 def charset 'utf-8' end |
#delete_header(name) ⇒ Object
82 83 84 |
# File 'lib/mlist/util/tmail_methods.rb', line 82 def delete_header(name) tmail[name] = nil end |
#from=(from_address) ⇒ Object
120 121 122 |
# File 'lib/mlist/util/tmail_methods.rb', line 120 def from=(from_address) tmail.from = sanitize_header(charset, 'from', from_address) end |
#headers=(updates) ⇒ Object
86 87 88 89 90 91 92 93 94 |
# File 'lib/mlist/util/tmail_methods.rb', line 86 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
124 125 126 |
# File 'lib/mlist/util/tmail_methods.rb', line 124 def in_reply_to=(*values) tmail.in_reply_to = sanitize_header(charset, 'in-reply-to', *values) end |
#mailer=(value) ⇒ Object
128 129 130 |
# File 'lib/mlist/util/tmail_methods.rb', line 128 def mailer=(value) write_header('x-mailer', value) end |
#message_id=(value) ⇒ Object
132 133 134 |
# File 'lib/mlist/util/tmail_methods.rb', line 132 def (value) tmail. = 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.
101 102 103 104 105 106 |
# File 'lib/mlist/util/tmail_methods.rb', line 101 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
112 113 114 |
# File 'lib/mlist/util/tmail_methods.rb', line 112 def to=(recipient_addresses) tmail.to = sanitize_header(charset, 'to', recipient_addresses) end |
#write_header(name, value) ⇒ Object
108 109 110 |
# File 'lib/mlist/util/tmail_methods.rb', line 108 def write_header(name, value) tmail[name] = sanitize_header(charset, name, value) end |