Class: Keystone::Mail::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/keystone/mail/message.rb

Direct Known Subclasses

MessageIso2022jp, MessageSjis

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opt = {}) ⇒ Message

普通なことをしたいならTMailを使いましょう



11
12
13
14
# File 'lib/keystone/mail/message.rb', line 11

def initialize(opt={})
  @subject, @body, @mail_from_text = "", "", nil
  set_option(opt)
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



6
7
8
# File 'lib/keystone/mail/message.rb', line 6

def body
  @body
end

#mail_fromObject

Returns the value of attribute mail_from.



6
7
8
# File 'lib/keystone/mail/message.rb', line 6

def mail_from
  @mail_from
end

#mail_from_textObject

Returns the value of attribute mail_from_text.



6
7
8
# File 'lib/keystone/mail/message.rb', line 6

def mail_from_text
  @mail_from_text
end

#mail_toObject

Returns the value of attribute mail_to.



6
7
8
# File 'lib/keystone/mail/message.rb', line 6

def mail_to
  @mail_to
end

#subjectObject

Returns the value of attribute subject.



6
7
8
# File 'lib/keystone/mail/message.rb', line 6

def subject
  @subject
end

Instance Method Details

#set_option(opt) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/keystone/mail/message.rb', line 27

def set_option(opt)
  @subject = opt[:subject] if opt.key?(:subject)
  @body = opt[:body] if opt.key?(:body)
  @body = opt[:mail_to] if opt.key?(:mail_to)
  @body = opt[:mail_from] if opt.key?(:mail_from)
  @mail_from_text = opt[:mail_from_text] if opt.key?(:mail_from_text)
end

#to_srcObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/keystone/mail/message.rb', line 16

def to_src
  header = ""
  header += "Date: #{time2str(Time.now)}\n"
  header += create_mailfrom_header
  header += create_mailto_header
  header += create_subject_header
  header += "\n"
  header += encode_body
  return header
end