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)

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

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


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

def from
  @from
end

#messageString

Returns The text message.

Returns:

  • (String)

    The text message


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

def message
  @message
end

#subjectString

Returns The subject of the email.

Returns:

  • (String)

    The subject of the email


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

def subject
  @subject
end

#toString

Returns The to field in the email.

Returns:

  • (String)

    The to field in the email


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

def to
  @to
end

Instance Method Details

#to_sString

Returns the raw SMS message

Returns:

  • (String)

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

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