Class: Henry::EmailClient
- Inherits:
-
Object
- Object
- Henry::EmailClient
- Defined in:
- lib/henry/email_client.rb
Overview
Email client to send reports by email
Class Method Summary collapse
-
.send_file(file_path, recipients, subject = '') ⇒ True, False
Sends a file by email (fails silentl).
-
.send_file!(file_path, recipients, subject = '') ⇒ Object
Sends a file by email (rise exeption on error).
-
.send_message(message, recipients, subject = '') ⇒ True, False
Sends a message by email (fails silently).
Instance Method Summary collapse
-
#send_message!(message, recipients, subject = '') ⇒ Object
Sends a message by email (rise exception on error).
Class Method Details
.send_file(file_path, recipients, subject = '') ⇒ True, False
Sends a file by email (fails silentl).
25 26 27 28 29 30 31 32 |
# File 'lib/henry/email_client.rb', line 25 def self.send_file(file_path, recipients, subject='') begin self.send_file!(file_path, recipients, subject) return true rescue Net::SMTPUnknownError, Net::SMTPAuthenticationError return false end end |
.send_file!(file_path, recipients, subject = '') ⇒ Object
Sends a file by email (rise exeption on error).
39 40 41 42 43 44 45 46 |
# File 'lib/henry/email_client.rb', line 39 def self.send_file!(file_path, recipients, subject='') Mail.deliver do from 'Henry Reports <[email protected]>' bcc recipients.join(',') subject subject add_file file_path end end |
.send_message(message, recipients, subject = '') ⇒ True, False
Sends a message by email (fails silently).
54 55 56 57 58 59 60 61 |
# File 'lib/henry/email_client.rb', line 54 def self.(, recipients, subject='') begin self.(, recipients, subject) return true rescue Net::SMTPUnknownError, Net::SMTPAuthenticationError return false end end |
Instance Method Details
#send_message!(message, recipients, subject = '') ⇒ Object
Sends a message by email (rise exception on error).
68 69 70 71 72 73 74 75 |
# File 'lib/henry/email_client.rb', line 68 def (, recipients, subject='') Mail.deliver do from 'Henry Reports <[email protected]>' bcc recipients.join(',') subject subject body end end |