Skip to content

Instantly share code, notes, and snippets.

@methodmissing
Created November 9, 2008 19:49
Show Gist options
  • Save methodmissing/23332 to your computer and use it in GitHub Desktop.
Save methodmissing/23332 to your computer and use it in GitHub Desktop.
# Delivers a TMail::Mail object. By default, it delivers the cached mail
# object (from the <tt>create!</tt> method). If no cached mail object exists, and
# no alternate has been given as the parameter, this will fail.
def deliver!(mail = @mail)
raise "no mail object available for delivery!" unless mail
unless logger.nil?
logger.info "Sent mail to #{Array(recipients).join(', ')}"
logger.debug "\n#{mail.encoded}"
end
begin
__send__("perform_delivery_#{delivery_method}", mail) if perform_deliveries
rescue Exception => e # Net::SMTP errors or sendmail pipe errors
raise e if raise_delivery_errors
end
return mail
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment