# Mail return value

**URL:** <https://www.ruby-forum.com/t/mail-return-value/159839>\
**Category:** Rails\
**Created:** [February 9, 2009, 10:16am UTC](https://www.ruby-forum.com/t/mail-return-value/159839 "2009-02-09T10:16:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![spacemeli](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@spacemeli](https://www.ruby-forum.com/u/spacemeli)\
**Post date:** [February 9, 2009, 10:16am UTC](https://www.ruby-forum.com/t/mail-return-value/159839/1 "2009-02-09T10:16:24Z")

</div>

Hi

I’m using this method to send emails

def send\_report(name, email, content)  
recipients email  
subject “My subject”  
from “removed\_email\_address@domain.invalid”  
body :content =\> content  
content\_type “text/html”  
end

I’d like to know if the email has been sent or not in order to print the  
correct message in my view.  
But I don’t know to catch the return value.  
Any ideas?

Thanks

---

<div class="post-metadata">

**Author:** ![spacemeli](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@spacemeli](https://www.ruby-forum.com/u/spacemeli)\
**Post date:** [February 9, 2009, 11:07am UTC](https://www.ruby-forum.com/t/mail-return-value/159839/2 "2009-02-09T11:07:32Z")

</div>

Melissa Melissa wrote:

> Hi
> 
> I’m using this method to send emails
> 
> def send\_report(name, email, content)  
> recipients email  
> subject “My subject”  
> from “removed\_email\_address@domain.invalid”  
> body :content =\> content  
> content\_type “text/html”  
> end
> 
> I’d like to know if the email has been sent or not in order to print the  
> correct message in my view.  
> But I don’t know to catch the return value.  
> Any ideas?
> 
> Thanks

The above action you wrote is only to construct mail. to sending mail  
you may need to move this action into your model then in controller use  
deliver\_send\_report it return message\_id if message successfully send.  
other wise nil.

eg.

msg\_id = your\_model.deliver\_send\_report(name, email,content)

- 

Hitesh
