Forum: Ruby on Rails UserMailer return boolean value

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
David (Guest)
on 2009-05-29 01:41
(Received via mailing list)
Is it possible to make is UserMailer returns a boolean value depending
on whether an email was sent or not?  I have a method to send maybe I
could put it in here somehow?

def send_initial
    UserMailer.deliver_initial(self)
end
Gavin M. (Guest)
on 2009-05-29 05:10
(Received via mailing list)
Hey David

The only thing I can think of here would be to set action mailer to
raise delivery errors in your development and production environments:
config.action_mailer.raise_delivery_errors = true

and then add something like the following to the method that sends the
mail:

  def my_mail_sending_method
    begin
      Mailer.deliver_my_email
    rescue
      return false # => returns false if any exceptions are raised
    end
    return true # => returns true if no exceptions are raised
  end


There might be a better answer out there though? :s
This topic is locked and can not be replied to.