Actionmailer SMTP server response

When sending mail through actionmailer, actionmailer receives a response from the SMTP server when it is normal, or when it is mistaken. Is there any way to get this response after sending mail? Also, if the SMTP server does not cause errors?

Our qmail mail server issues a handler identifier that we want to use to track email.

As an example, the server response is as follows:

250 ok 1308235825 qp ​​17832

+5
source share
2 answers

return_response: true smtp message.deliver! deliver. SMTP-, Net::SMTP::Response, , .

, , Net:: SMTP.

+5

, :

base.rb

  # Register an Observer which will be notified when mail is delivered.
  # Either a class or a string can be passed in as the Observer. If a string is passed in
  # it will be <tt>constantize</tt>d.
  def register_observer(observer)
    delivery_observer = (observer.is_a?(String) ? observer.constantize : observer)
    Mail.register_observer(delivery_observer)
  end

, :

class MailObserver
  def self.delivered_email(message)
    logger_info "Sent Message: #{message}"
  end
end

ActionMailer::Base.register_observer(MailObserver)

, , .

+2

All Articles