Class: Outbox::Messages::Email
- Defined in:
- lib/outbox/messages/email.rb
Overview
Email messages use the same interface for composing emails as Mail::Message from the mail gem. The only difference is the abstraction of the client interface, which allows you to send the email using whatever client you wish.
email = Outbox::Messages::Email.new do
to '[email protected]'
from 'Mikel Lindsaar <[email protected]>'
subject 'First multipart email sent with Mail'
text_part do
body 'This is plain text'
end
html_part do
content_type 'text/html; charset=UTF-8'
body '<h1>This is HTML</h1>'
end
end
email.client :mandrill, api_key: '...'
email.deliver
Instance Method Summary collapse
-
#audience=(audience) ⇒ Object
:nodoc:.
-
#initialize(fields = nil, &block) ⇒ Email
constructor
:nodoc:.
-
#message_object ⇒ Object
Returns the internal Mail::Message instance.
Methods inherited from Base
Methods included from Outbox::MessageFields
#[], #[]=, #fields, #fields=, included, #validate_fields
Methods included from Outbox::MessageClients
Constructor Details
#initialize(fields = nil, &block) ⇒ Email
:nodoc:
44 45 46 47 |
# File 'lib/outbox/messages/email.rb', line 44 def initialize(fields = nil, &block) # :nodoc: @message = ::Mail::Message.new super end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (protected)
68 69 70 71 72 73 74 |
# File 'lib/outbox/messages/email.rb', line 68 def method_missing(method, *args, &block) if @message.respond_to?(method) @message.public_send(method, *args, &block) else super end end |
Instance Method Details
#audience=(audience) ⇒ Object
:nodoc:
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/outbox/messages/email.rb', line 54 def audience=(audience) # :nodoc: case audience when String, Array self.to = audience else audience = Outbox::Accessor.new(audience) self.to = audience[:to] self.cc = audience[:cc] self.bcc = audience[:bcc] end end |
#message_object ⇒ Object
Returns the internal Mail::Message instance
50 51 52 |
# File 'lib/outbox/messages/email.rb', line 50 def @message end |