Class: Gophish::Smtp

Inherits:
Base
  • Object
show all
Defined in:
lib/gophish/smtp.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

all, configuration, delete, #destroy, find, get, #initialize, #new_record?, #persisted?, post, put, resource_name, #save, #update_attributes

Constructor Details

This class inherits a constructor from Gophish::Base

Class Method Details

.resource_pathObject



6
7
8
# File 'lib/gophish/smtp.rb', line 6

def self.resource_path
  '/smtp'
end

Instance Method Details

#add_header(key, value) ⇒ Object



39
40
41
42
# File 'lib/gophish/smtp.rb', line 39

def add_header(key, value)
  headers << { key:, value: }
  headers_will_change!
end

#body_for_createObject



29
30
31
32
33
34
35
36
37
# File 'lib/gophish/smtp.rb', line 29

def body_for_create
  {
    name:, username:, password:, host:,
    interface_type:,
    from_address:,
    ignore_cert_errors:,
    headers:
  }
end

#has_authentication?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/gophish/smtp.rb', line 58

def has_authentication?
  !username.blank? && !password.blank?
end

#has_headers?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/gophish/smtp.rb', line 50

def has_headers?
  !headers.empty?
end

#header_countObject



54
55
56
# File 'lib/gophish/smtp.rb', line 54

def header_count
  headers.length
end

#ignores_cert_errors?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/gophish/smtp.rb', line 62

def ignores_cert_errors?
  ignore_cert_errors == true
end

#remove_header(key) ⇒ Object



44
45
46
47
48
# File 'lib/gophish/smtp.rb', line 44

def remove_header(key)
  original_size = headers.size
  headers.reject! { |header| header[:key] == key || header['key'] == key }
  headers_will_change! if headers.size != original_size
end