Module: Mail::CheckDeliveryParams

Included in:
FileDelivery, SMTP, SMTPConnection, Sendmail, TestMailer
Defined in:
lib/mail/check_delivery_params.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) check_delivery_params(mail)



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/mail/check_delivery_params.rb', line 3

def check_delivery_params(mail)
  if mail.smtp_envelope_from.blank?
    raise ArgumentError.new('An SMTP From address is required to send a message. Set the message smtp_envelope_from, return_path, sender, or from address.')
  end

  if mail.smtp_envelope_to.blank?
    raise ArgumentError.new('An SMTP To address is required to send a message. Set the message smtp_envelope_to, to, cc, or bcc address.')
  end

  message = mail.encoded if mail.respond_to?(:encoded)
  if message.blank?
    raise ArgumentError.new('An encoded message is required to send an email')
  end

  [mail.smtp_envelope_from, mail.smtp_envelope_to, message]
end