Class: RhizMail::Mailer
- Inherits:
-
ContextualService::Service
- Object
- ContextualService::Service
- RhizMail::Mailer
- Defined in:
- lib/rhizmail.rb
Overview
The Mailer is the class used to handle mail delivery. However, you usually don’t need to manipulate it directly; it’s usually sufficient to call Message#deliver.
Constant Summary collapse
- @@smtpServer =
'localhost'
- @@smtpClass =
Net::SMTP
- @@smtpLogin =
nil
- @@smtpPassword =
nil
- @@smtpAuthType =
nil
- @@messagesSent =
[]
Class Method Summary collapse
-
.flush ⇒ Object
Flushes record of messages sent.
- .smtp_auth_type ⇒ Object
- .smtp_auth_type=(smtpAuthType) ⇒ Object
-
.smtp_class=(smtpClass) ⇒ Object
:nodoc:.
- .smtp_login ⇒ Object
- .smtp_login=(smtpLogin) ⇒ Object
- .smtp_password ⇒ Object
- .smtp_password=(smtpPassword) ⇒ Object
- .smtp_server ⇒ Object
- .smtp_server=(smtpServer) ⇒ Object
Instance Method Summary collapse
-
#messages_sent ⇒ Object
Returns an array of what messages have been sent.
-
#send_message(email) ⇒ Object
Sends an email message.
Class Method Details
.flush ⇒ Object
Flushes record of messages sent.
116 |
# File 'lib/rhizmail.rb', line 116 def self.flush; @@messagesSent = []; end |
.smtp_auth_type ⇒ Object
107 108 109 |
# File 'lib/rhizmail.rb', line 107 def self.smtp_auth_type @@smtpAuthType end |
.smtp_auth_type=(smtpAuthType) ⇒ Object
111 112 113 |
# File 'lib/rhizmail.rb', line 111 def self.smtp_auth_type=(smtpAuthType) @@smtpAuthType = smtpAuthType end |
.smtp_class=(smtpClass) ⇒ Object
:nodoc:
118 119 120 |
# File 'lib/rhizmail.rb', line 118 def self.smtp_class=(smtpClass) # :nodoc: @@smtpClass = smtpClass; end |
.smtp_login ⇒ Object
91 92 93 |
# File 'lib/rhizmail.rb', line 91 def self.smtp_login @@smtpLogin end |
.smtp_login=(smtpLogin) ⇒ Object
95 96 97 |
# File 'lib/rhizmail.rb', line 95 def self.smtp_login=(smtpLogin) @@smtpLogin = smtpLogin end |
.smtp_password ⇒ Object
99 100 101 |
# File 'lib/rhizmail.rb', line 99 def self.smtp_password @@smtpPassword end |
.smtp_password=(smtpPassword) ⇒ Object
103 104 105 |
# File 'lib/rhizmail.rb', line 103 def self.smtp_password=(smtpPassword) @@smtpPassword = smtpPassword end |
.smtp_server ⇒ Object
83 84 85 |
# File 'lib/rhizmail.rb', line 83 def self.smtp_server @@smtpServer end |
.smtp_server=(smtpServer) ⇒ Object
87 88 89 |
# File 'lib/rhizmail.rb', line 87 def self.smtp_server=(smtpServer) @@smtpServer = smtpServer end |
Instance Method Details
#messages_sent ⇒ Object
Returns an array of what messages have been sent.
139 |
# File 'lib/rhizmail.rb', line 139 def ; @@messagesSent; end |
#send_message(email) ⇒ Object
Sends an email message. email
needs to respond to verify_sendable
; Mailer##send_message will call verify_sendable
before sending the email.
124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/rhizmail.rb', line 124 def (email) email.verify_sendable msg = [] email.headers.each { |header| msg << "#{header}\n" } msg << "\n" msg << email.body @@smtpClass.start( @@smtpServer, @@smtpLogin, @@smtpPassword, @@smtpAuthType ) do |smtp| smtp.sendmail( msg, email.from_address, [ email.to_address ] ) end @@messagesSent << email end |