Module: BioDSL::EmailHelper

Included in:
Pipeline
Defined in:
lib/BioDSL/helpers/email_helper.rb

Overview

Namespace for EmailHelper.

Instance Method Summary collapse

Instance Method Details

#compose_mail(html_part) ⇒ Mail

Compose an email.

Parameters:

  • html_part (Mail::Part)

    The email body.

Returns:

  • (Mail)

    Mail to be sent.



53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/BioDSL/helpers/email_helper.rb', line 53

def compose_mail(html_part)
  mail = Mail.new
  mail[:from]    = "do-not-reply@#{`hostname -f`.strip}"
  mail[:to]      = @options[:email]
  mail[:subject] = @options[:subject] || to_s.first(30)
  mail.html_part = html_part
  mail.delivery_method :smtp,
                       address: 'localhost',
                       port: 25,
                       enable_starttls_auto: false
  mail
end

#send_email(pipeline) ⇒ Object

Send email notification to email address specfied in @options, including a optional subject specified in @options, that will otherwise default to self.to_s. The body of the email will be an HTML report.

Parameters:



37
38
39
40
41
42
43
44
45
46
# File 'lib/BioDSL/helpers/email_helper.rb', line 37

def send_email(pipeline)
  return unless @options[:email]

  html_part = Mail::Part.new do
    content_type 'text/html; charset=UTF-8'
    body BioDSL::HtmlReport.new(pipeline).to_html
  end

  compose_mail(html_part).deliver!
end