Class: Inkcite::Mailer::SmtpMailer

Inherits:
Base
  • Object
show all
Defined in:
lib/inkcite/mailer.rb

Instance Method Summary collapse

Instance Method Details

#send!(config, view, _subject, opt) ⇒ Object



175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/inkcite/mailer.rb', line 175

def send! config, view, _subject, opt

  Mail.defaults do
    delivery_method :smtp, {
            :address => config[:host],
            :port => config[:port],
            :user_name => config[:username],
            :password => config[:password],
            :authentication => :plain,
            :enable_starttls_auto => true
        }
  end

  # The address of the developer
  _from = config[:from]

  # True if the developer should be bcc'd.
  _bcc = !!opt[:bcc]

  mail = Mail.new do

    to opt[:to] || _from
    cc opt[:cc]
    from _from
    subject _subject

    bcc(_from) if _bcc

    html_part do
      content_type 'text/html; charset=UTF-8'
      body view.render!
    end

  end

  mail.deliver!

end