Class: Rex::Proto::Mms::Client
- Inherits:
-
Object
- Object
- Rex::Proto::Mms::Client
- Defined in:
- lib/rex/proto/mms/client.rb
Instance Attribute Summary collapse
-
#carrier ⇒ Symbol
The service provider for the phone numbers.
-
#smtp_server ⇒ Rex::Proto::Mms::Model::Smtp
The Smtp object with the Smtp settings.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Rex::Proto::Mms::Client
constructor
Initializes the Client object.
-
#send_mms_to_phones(phone_numbers, subject, message, attachment_path = nil, ctype = nil) ⇒ void
Sends a media text to multiple recipients.
-
#validate_carrier! ⇒ Object
Validates the carrier parameter.
Constructor Details
#initialize(opts = {}) ⇒ Rex::Proto::Mms::Client
Initializes the Client object.
24 25 26 27 28 29 |
# File 'lib/rex/proto/mms/client.rb', line 24 def initialize(opts={}) self.carrier = opts[:carrier] self.smtp_server = opts[:smtp_server] validate_carrier! end |
Instance Attribute Details
#carrier ⇒ Symbol
Returns The service provider for the phone numbers.
10 11 12 |
# File 'lib/rex/proto/mms/client.rb', line 10 def carrier @carrier end |
#smtp_server ⇒ Rex::Proto::Mms::Model::Smtp
Returns The Smtp object with the Smtp settings.
14 15 16 |
# File 'lib/rex/proto/mms/client.rb', line 14 def smtp_server @smtp_server end |
Instance Method Details
#send_mms_to_phones(phone_numbers, subject, message, attachment_path = nil, ctype = nil) ⇒ void
This method returns an undefined value.
Sends a media text to multiple recipients.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/rex/proto/mms/client.rb', line 41 def send_mms_to_phones(phone_numbers, subject, , =nil, ctype=nil) carrier = Rex::Proto::Mms::Model::GATEWAYS[self.carrier] recipients = phone_numbers.collect { |p| "#{p}@#{carrier}" } address = self.smtp_server.address port = self.smtp_server.port username = self.smtp_server.username password = self.smtp_server.password helo_domain = self.smtp_server.helo_domain login_type = self.smtp_server.login_type from = self.smtp_server.from smtp = Net::SMTP.new(address, port) begin smtp.enable_starttls_auto smtp.start(helo_domain, username, password, login_type) do recipients.each do |r| = Rex::Proto::Mms::Model::Message.new( message: , content_type: ctype, attachment_path: , from: from, to: r, subject: subject ) smtp.(.to_s, from, r) end end rescue Net::SMTPAuthenticationError => e raise Rex::Proto::Mms::Exception, e. ensure smtp.finish if smtp && smtp.started? end end |