Revision 979a7aaa
Added by Marc Dequènes almost 11 years ago
lib/cyborghood/mail.rb | ||
---|---|---|
def initialize(msg = nil)
|
||
@config = Config.instance
|
||
|
||
# needs to be initialized before _any_ ::Mail object is created
|
||
unless self.class.delivery_initialized
|
||
params = @config.mail.smtp.nil? ? {} : @config.mail.smtp.to_h.symbolize_keys
|
||
|
||
::Mail.defaults do
|
||
delivery_method :smtp, params
|
||
end
|
||
|
||
self.class.delivery_initialized = true
|
||
end
|
||
|
||
if msg.nil?
|
||
@mail = ::Mail.new
|
||
set_custom_headers
|
||
... | ... | |
s
|
||
end
|
||
|
||
def deliver
|
||
unless self.class.delivery_initialized
|
||
params = @config.mail.smtp.nil? ? {} : @config.mail.smtp.to_h.symbolize_keys
|
||
|
||
::Mail.defaults do
|
||
delivery_method :smtp, params
|
||
end
|
||
|
||
self.class.delivery_initialized = true
|
||
end
|
||
|
||
@mail.deliver
|
||
end
|
||
|
||
def to_s
|
||
@mail.to_s
|
||
end
|
Also available in: Unified diff
[fix] ruby-mail delivery method needs to be setup before any Mail object is created