Class: MailHandler::Sending::SMTPSender
- Defined in:
- lib/mailhandler/sending/smtp.rb
Overview
class which describes methods to send and receive emails
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#authentication ⇒ Object
Returns the value of attribute authentication.
-
#domain ⇒ Object
Returns the value of attribute domain.
-
#open_timeout ⇒ Object
Returns the value of attribute open_timeout.
-
#password ⇒ Object
Returns the value of attribute password.
-
#port ⇒ Object
Returns the value of attribute port.
-
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
-
#save_response ⇒ Object
Returns the value of attribute save_response.
-
#use_ssl ⇒ Object
Returns the value of attribute use_ssl.
-
#username ⇒ Object
Returns the value of attribute username.
Attributes inherited from Sender
Instance Method Summary collapse
-
#initialize ⇒ SMTPSender
constructor
A new instance of SMTPSender.
- #send(email) ⇒ Object
- #send_raw_email(text_email, smtp_from, smtp_to) ⇒ Object
Constructor Details
#initialize ⇒ SMTPSender
Returns a new instance of SMTPSender.
21 22 23 24 25 26 27 28 29 |
# File 'lib/mailhandler/sending/smtp.rb', line 21 def initialize @type = :smtp @authentication = 'plain' @use_ssl = false @save_response = true @open_timeout = 60 @read_timeout = 60 end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
9 10 11 |
# File 'lib/mailhandler/sending/smtp.rb', line 9 def address @address end |
#authentication ⇒ Object
Returns the value of attribute authentication.
9 10 11 |
# File 'lib/mailhandler/sending/smtp.rb', line 9 def authentication @authentication end |
#domain ⇒ Object
Returns the value of attribute domain.
9 10 11 |
# File 'lib/mailhandler/sending/smtp.rb', line 9 def domain @domain end |
#open_timeout ⇒ Object
Returns the value of attribute open_timeout.
17 18 19 |
# File 'lib/mailhandler/sending/smtp.rb', line 17 def open_timeout @open_timeout end |
#password ⇒ Object
Returns the value of attribute password.
9 10 11 |
# File 'lib/mailhandler/sending/smtp.rb', line 9 def password @password end |
#port ⇒ Object
Returns the value of attribute port.
9 10 11 |
# File 'lib/mailhandler/sending/smtp.rb', line 9 def port @port end |
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
17 18 19 |
# File 'lib/mailhandler/sending/smtp.rb', line 17 def read_timeout @read_timeout end |
#save_response ⇒ Object
Returns the value of attribute save_response.
17 18 19 |
# File 'lib/mailhandler/sending/smtp.rb', line 17 def save_response @save_response end |
#use_ssl ⇒ Object
Returns the value of attribute use_ssl.
9 10 11 |
# File 'lib/mailhandler/sending/smtp.rb', line 9 def use_ssl @use_ssl end |
#username ⇒ Object
Returns the value of attribute username.
9 10 11 |
# File 'lib/mailhandler/sending/smtp.rb', line 9 def username @username end |
Instance Method Details
#send(email) ⇒ Object
31 32 33 34 35 |
# File 'lib/mailhandler/sending/smtp.rb', line 31 def send(email) verify_email(email) email = configure_sending(email) save_response ? email.deliver! : email.deliver end |
#send_raw_email(text_email, smtp_from, smtp_to) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/mailhandler/sending/smtp.rb', line 37 def send_raw_email(text_email, smtp_from, smtp_to) response = init_net_smtp.start(domain, username, password, authentication) do |smtp| smtp.(text_email, smtp_from, smtp_to) end save_response ? response : nil end |