# UserMailer return boolean value

**URL:** <https://www.ruby-forum.com/t/usermailer-return-boolean-value/169070>\
**Category:** Rails\
**Created:** [May 28, 2009, 11:41pm UTC](https://www.ruby-forum.com/t/usermailer-return-boolean-value/169070 "2009-05-28T23:41:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [May 28, 2009, 11:41pm UTC](https://www.ruby-forum.com/t/usermailer-return-boolean-value/169070/1 "2009-05-28T23:41:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [May 29, 2009, 3:10am UTC](https://www.ruby-forum.com/t/usermailer-return-boolean-value/169070/2 "2009-05-29T03:10:51Z")

</div>

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
