Class: SendGmail::Objects::Mail

Inherits:
Object
  • Object
show all
Defined in:
lib/send_gmail/objects/mail.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Mail

Returns a new instance of Mail.



7
8
9
10
11
# File 'lib/send_gmail/objects/mail.rb', line 7

def initialize(params = {})
  params.each do |key, value|
    instance_variable_set("@#{key}", value)
  end
end

Instance Attribute Details

#bccObject

Returns the value of attribute bcc.



5
6
7
# File 'lib/send_gmail/objects/mail.rb', line 5

def bcc
  @bcc
end

#bodyObject

Returns the value of attribute body.



5
6
7
# File 'lib/send_gmail/objects/mail.rb', line 5

def body
  @body
end

#ccObject

Returns the value of attribute cc.



5
6
7
# File 'lib/send_gmail/objects/mail.rb', line 5

def cc
  @cc
end

#dateObject

Returns the value of attribute date.



5
6
7
# File 'lib/send_gmail/objects/mail.rb', line 5

def date
  @date
end

#fromObject

Returns the value of attribute from.



5
6
7
# File 'lib/send_gmail/objects/mail.rb', line 5

def from
  @from
end

#subjectObject

Returns the value of attribute subject.



5
6
7
# File 'lib/send_gmail/objects/mail.rb', line 5

def subject
  @subject
end

#toObject

Returns the value of attribute to.



5
6
7
# File 'lib/send_gmail/objects/mail.rb', line 5

def to
  @to
end

Instance Method Details

#to_raw_dataObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/send_gmail/objects/mail.rb', line 13

def to_raw_data
  msg = body.to_s
  from_text = from
  to_text = to
  subject_text  = subject

  mail = ::Mail.new do
    from    from_text
    to      to_text
    subject subject_text
    body    msg
  end
  raw = mail.to_s
  raw = "Bcc:#{bcc}\r\n#{raw}" unless bcc.nil?
  raw = "Cc:#{cc}\r\n#{raw}" unless cc.nil?
  raw
end