# SMTP errror handling

**URL:** <https://www.ruby-forum.com/t/smtp-errror-handling/144922>\
**Category:** Rails\
**Created:** [August 4, 2008, 1:00pm UTC](https://www.ruby-forum.com/t/smtp-errror-handling/144922 "2008-08-04T13:00:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrbless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ba9def/32.png) [@mrbless](https://www.ruby-forum.com/u/mrbless)\
**Post date:** [August 4, 2008, 1:00pm UTC](https://www.ruby-forum.com/t/smtp-errror-handling/144922/1 "2008-08-04T13:00:37Z")

</div>

When I try to send the email with invalid recipient like  
removed\_email\_address@domain.invalid I get following error 550 unknown recipient. I try  
to catch the error with begin and catch but error is not caught.  
Any idea

---

<div class="post-metadata">

**Author:** ![mrbless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ba9def/32.png) [@mrbless](https://www.ruby-forum.com/u/mrbless)\
**Post date:** [August 4, 2008, 1:53pm UTC](https://www.ruby-forum.com/t/smtp-errror-handling/144922/2 "2008-08-04T13:53:22Z")

</div>

If you want to rescue an exception you need to use rescue, not  
catch( which is something rather different in ruby)

Sent from my iPhone

---

<div class="post-metadata">

**Author:** ![mrbless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ba9def/32.png) [@mrbless](https://www.ruby-forum.com/u/mrbless)\
**Post date:** [August 5, 2008, 7:52am UTC](https://www.ruby-forum.com/t/smtp-errror-handling/144922/3 "2008-08-05T07:52:49Z")

</div>

# Sorry I mean rescue but I type catch. My code is like this

begin  
UserMailer.deliver\_sent\_to\_friend(from,recipient, subject, message)

```
flash[:notice] = "Message sent."

```

# rescue flash[:notice]=“Message not sent” end

However problem persist.

On Aug 4, 4:52 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
