Class: Ruport::Report::Mailer
- Inherits:
-
Object
- Object
- Ruport::Report::Mailer
- Defined in:
- lib/ruport/report/mailer.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
The body of the message to be sent.
-
#recipients ⇒ Object
A list of email addresses to send the message to.
Instance Method Summary collapse
-
#initialize(mailer_label = :default) ⇒ Mailer
constructor
A new instance of Mailer.
- #select_mailer(label) ⇒ Object
-
#send_report(report_name = "No Subject") ⇒ Object
This takes report_name as argument and sends the contents of @body to.
Constructor Details
#initialize(mailer_label = :default) ⇒ Mailer
Returns a new instance of Mailer.
12 13 14 15 16 |
# File 'lib/ruport/report/mailer.rb', line 12 def initialize( mailer_label=:default ) select_mailer(mailer_label) @body = "" @recipients = [] end |
Instance Attribute Details
#body ⇒ Object
The body of the message to be sent
22 23 24 |
# File 'lib/ruport/report/mailer.rb', line 22 def body @body end |
#recipients ⇒ Object
A list of email addresses to send the message to.
19 20 21 |
# File 'lib/ruport/report/mailer.rb', line 19 def recipients @recipients end |
Instance Method Details
#select_mailer(label) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/ruport/report/mailer.rb', line 35 def select_mailer(label) mailer = Ruport::Config.mailers[label] @host = mailer.host @user = mailer.user @password = mailer.password @address = mailer.address @port = mailer.port || 25 @auth = mailer.auth_type || :plain end |
#send_report(report_name = "No Subject") ⇒ Object
This takes report_name as argument and sends the contents of @body to
26 27 28 29 30 31 32 33 |
# File 'lib/ruport/report/mailer.rb', line 26 def send_report(report_name="No Subject") return if @body.empty? Net::SMTP.start(@host,@port,@host,@user,@password,@auth) do |smtp| smtp.( "Subject: #{report_name}\n\n#{@body}", @address, @recipients ) end end |