Class: RhizMail::Mailer

Inherits:
ContextualService::Service
  • Object
show all
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

Instance Method Summary collapse

Class Method Details

.flushObject

Flushes record of messages sent.



116
# File 'lib/rhizmail.rb', line 116

def self.flush; @@messagesSent = []; end

.smtp_auth_typeObject



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_loginObject



91
92
93
# File 'lib/rhizmail.rb', line 91

def self.
	@@smtpLogin
end

.smtp_login=(smtpLogin) ⇒ Object



95
96
97
# File 'lib/rhizmail.rb', line 95

def self.smtp_login=(smtpLogin)
	@@smtpLogin = smtpLogin
end

.smtp_passwordObject



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_serverObject



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_sentObject

Returns an array of what messages have been sent.



139
# File 'lib/rhizmail.rb', line 139

def messages_sent; @@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 send_message(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