Class: AppMail::SendRawMessage
- Inherits:
-
Object
- Object
- AppMail::SendRawMessage
- Defined in:
- lib/app_mail/send_raw_message.rb
Instance Method Summary collapse
- #data(data) ⇒ Object
-
#initialize(client) ⇒ SendRawMessage
constructor
A new instance of SendRawMessage.
- #mail_from(address) ⇒ Object
- #rcpt_to(*addresses) ⇒ Object
- #send! ⇒ Object
Constructor Details
#initialize(client) ⇒ SendRawMessage
Returns a new instance of SendRawMessage.
7 8 9 10 |
# File 'lib/app_mail/send_raw_message.rb', line 7 def initialize(client) @client = client @attributes = {} end |
Instance Method Details
#data(data) ⇒ Object
32 33 34 |
# File 'lib/app_mail/send_raw_message.rb', line 32 def data(data) @attributes[:data] = Base64.encode64(data) end |
#mail_from(address) ⇒ Object
23 24 25 |
# File 'lib/app_mail/send_raw_message.rb', line 23 def mail_from(address) @attributes[:mail_from] = address end |
#rcpt_to(*addresses) ⇒ Object
27 28 29 30 |
# File 'lib/app_mail/send_raw_message.rb', line 27 def rcpt_to(*addresses) @attributes[:rcpt_to] ||= [] @attributes[:rcpt_to] += addresses end |
#send! ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/app_mail/send_raw_message.rb', line 12 def send! api = @client.moonrope.request(:send, :raw, @attributes) if api.success? SendResult.new(@client, api.data) elsif api.status == 'error' raise SendError.new(api.data['code'], api.data['message']) else raise Error, "Couldn't send message" end end |