Class: Rex::Proto::Sms::Model::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/rex/proto/sms/model/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Rex::Proto::Sms::Model::Message

Initializes the SMTP object.

Parameters:

  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :from (String)
  • :to (String)
  • :message (String)


36
37
38
39
40
41
# File 'lib/rex/proto/sms/model/message.rb', line 36

def initialize(opts={})
  self.from = opts[:from]
  self.to = opts[:to]
  self.message = opts[:message]
  self.subject = opts[:subject]
end

Instance Attribute Details

#fromString

Returns The from field in the email.

Returns:

  • (String)

    The from field in the email



17
18
19
# File 'lib/rex/proto/sms/model/message.rb', line 17

def from
  @from
end

#messageString

Returns The text message.

Returns:

  • (String)

    The text message



12
13
14
# File 'lib/rex/proto/sms/model/message.rb', line 12

def message
  @message
end

#subjectString

Returns The subject of the email.

Returns:

  • (String)

    The subject of the email



25
26
27
# File 'lib/rex/proto/sms/model/message.rb', line 25

def subject
  @subject
end

#toString

Returns The to field in the email.

Returns:

  • (String)

    The to field in the email



21
22
23
# File 'lib/rex/proto/sms/model/message.rb', line 21

def to
  @to
end

Instance Method Details

#to_sString

Returns the raw SMS message

Returns:

  • (String)


47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/rex/proto/sms/model/message.rb', line 47

def to_s
  body = Rex::MIME::Message.new
  body.add_part(self.message, 'text/plain; charset=UTF-8', nil)

  sms = "MIME-Version: 1.0\n"
  sms << "From: #{self.from}\n"
  sms << "To: #{self.to}\n"
  sms << "Subject: #{self.subject}\n"
  sms << "Content-Type: multipart/alternative; boundary=#{body.bound}\n"
  sms << "\n"
  sms << body.to_s

  sms
end