Tutorial :Rails 2.3 action mailer Net::SMTPFatalError


I am sending out a confirmation email on save. When an email address in the 'CC' list is invalid I get the following error

Net::SMTPFatalError (550 5.1.1 ... User unknown ):

and the transaction is not saved even though it is called from the after_save method in the model observer. Should'nt the transaction be saved before the error.

Also, when I set the raise_delivery_errors to false in my config file, the error is not raised and the transaction is saved but the email is not sent to the members of the 'To' list and the 'CC' list even if one of the email addresses in the 'CC' list is invalid.

The system should atleast send emails to people with valid email addresses. Any suggessions to fix this issue.

thanks, ash


Sorry, your callbacks run in the context of the transaction, and returning false or throwing an exception causes the transaction to rollback: http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html

Can you catch that exception in your code, log it, and not re-raise it?

You could use your after_save to fire a worker queue or delayed job.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »