lib/eco-rake/utils/mailer.rb in eco-rake-0.2.6 vs lib/eco-rake/utils/mailer.rb in eco-rake-0.2.7

- old
+ new

@@ -12,49 +12,14 @@ # 4. `MAILER_FROM` class Mailer DEFAULT_PROVIDER = :sendgrid attr_reader :provider + def initialize(provider: DEFAULT_PROVIDER) @provider = provider || DEFAULT_PROVIDER end - # Sends an email - # @param to [String] destination email address - # @param subject [String] subject of the email - # @param body [String] `html` or plain text message - # @param from [String] the email address this is send **from** - def mail(to:, subject:, body:, from: nil, cc: nil, bcc: nil) - unless configured? - puts "Mailer: You are missing configuration parameters. Review your .env file" - return false - end - - ses.send_email( - destination: fetch_to(to: to, cc: cc, bcc: bcc), - source: fetch_from(from), - message: { - subject: { - charset: "UTF-8", - data: subject - }, - body: { - # NOTEL: `html:` will let you send html instead - # you can use both at once if you like - text: { - charset: "UTF-8", - data: body - } - } - } - ).tap do |response| - puts "Sent email to #{to} (MessageId: #{response.message_id})" - end - rescue StandardError => err - msg = "The mailer generated an exception:\n" - msg << err.patch_full_message(trace_count: 15) - puts msg - end # Sends an email # @param to [String] destination email address # @param subject [String] subject of the email # @param body [String] `html` or plain text message def mail(subject:, body:, to: nil, cc: nil, bcc: nil)