Class: Lazylead::Postman
- Inherits:
-
Object
- Object
- Lazylead::Postman
- Defined in:
- lib/lazylead/postman.rb
Overview
#/DEV Merge Smtp and Postman objects. There might be different postman’s based on different mail servers, thus its better to keep together the instantiation and sending. For each type of mail servers we should have separate object.
#/DEV TestMail.deliveries -> store all emails to the files in /test/resources/testmailer/*.html. Right now after each test with email sending we taking the body and test it content. Quite ofter we need to check visual style in mails, etc, thus its better to store them on disk.
A postman to send emails.
- Author
-
Yurii Dubinka ([email protected])
- Copyright
-
Copyright © 2019-2020 Yurii Dubinka
- License
-
MIT
Instance Method Summary collapse
-
#initialize(log = Log.new) ⇒ Postman
constructor
A new instance of Postman.
-
#make_email(opts) ⇒ Object
Construct an email based on input arguments.
-
#send(opts) ⇒ Object
Send an email.
Constructor Details
Instance Method Details
#make_email(opts) ⇒ Object
Construct an email based on input arguments
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/lazylead/postman.rb', line 65 def make_email(opts) mail = Mail.new mail.to opts.msg_to mail.from opts.msg_from mail.cc opts.msg_cc if opts.key? "cc" mail.subject opts["subject"] mail.html_part do content_type "text/html; charset=UTF-8" body opts.msg_body end opts..each { |f| mail.add_file f } mail end |
#send(opts) ⇒ Object
Send an email.
- :opts
-
the mail configuration like to, from, cc, subject, template.
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/lazylead/postman.rb', line 53 def send(opts) if opts.msg_to.empty? @log.warn "ll-013: Email can't be sent to '#{opts.msg_to}," \ " more: '#{opts}'" else mail = make_email(opts) mail.deliver @log.debug "#{__FILE__} sent '#{mail.subject}' to '#{mail.to}'." end end |