Hi,
I''ve got actionmailer set to raise an error on failure. When a user
submits my contact form, and they use a bogus address
''s@s.com'', then
the following error occurs in the production.log:
Net::SMTPFatalError (553 5.1.8 Sender address <s@s.com> domain does not
exist)
What I would like to do is catch the error, add the message to the
errors for the email address field, and redisplay the form.
I''m sure that ruby/rails can somehow catch the error, probably with
some
sort of rescue. I couldn''t find much in the way of reference to how to
use the rescue handling on rails. Are there any docs for this, beyond
just the rdoc?
Here is my existing action:
def contact
@contact = Contact.new
if request.post?
@contact.attributes = params[:contact]
if @contact.valid?
email = UserNotifier.create_contact_request(@contact)
UserNotifier.deliver(email)
render(:text => ''<p
class="fieldWithErrors">Thank you for your
comment or question. Our staff will reply as soon as
possible.</p>'',
:layout => ''/layouts/application.rhtml'')
end
else
if logged_in?
@contact.name = current_user.fullname
@contact.telephone = current_user.telephone
@contact.email = current_user.email
end
end
end
Thanks!
Regards,
Rich
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---