Class: JavaMail::Mailer
- Inherits:
-
Object
- Object
- JavaMail::Mailer
- Defined in:
- lib/java_mail/mailer.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(settings = {}) ⇒ Mailer
constructor
A new instance of Mailer.
- #open(&block) ⇒ Object
- #send_message(tmail) ⇒ Object
Constructor Details
#initialize(settings = {}) ⇒ Mailer
Returns a new instance of Mailer.
3 4 5 6 7 8 |
# File 'lib/java_mail/mailer.rb', line 3 def initialize(settings = {}) @config = JavaMail::Config.new(settings) @session = JavaMail::Java::Session.getInstance(@config.session_properties) @session.setDebug(@config.debug?) @transport = @session.getTransport end |
Class Method Details
.open(settings, &block) ⇒ Object
10 11 12 |
# File 'lib/java_mail/mailer.rb', line 10 def self.open(settings, &block) self.new(settings).open(&block) end |
Instance Method Details
#open(&block) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/java_mail/mailer.rb', line 14 def open(&block) begin open_transport unless transport_ready? block.call(self) rescue Exception => e raise JavaMail::JavaMailError.new(e) ensure close_transport if transport_ready? end end |
#send_message(tmail) ⇒ Object
25 26 27 28 |
# File 'lib/java_mail/mailer.rb', line 25 def (tmail) raise JavaMail::JavaMailError.new("JavaMail Transport is not connected") unless transport_ready? (tmail, @transport) end |