Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exceptions can be raised by action mailer

I had a look at the class but could not see a list of possible exceptions that can be raised from delivering smtp email in rails 3.

Has anyone any idea?

like image 205
Niall Avatar asked Feb 08 '12 13:02

Niall


People also ask

What is Action Mailer and how do I use it?

Luckily for anyone learning Ruby on Rails, or anyone currently working with Rails, Action Mailer is here to help. What is action mailer? According to the Ruby on Rails Guides, “Action Mailer allows you to send emails from your application using mailer classes and views”.

How to implement email interceptors in Action Mailer framework?

An interceptor class must implement the :delivering_email (message) method which will be called before the email is sent. Before the interceptor can do its job you need to register it with the Action Mailer framework. You can do this in an initializer file config/initializers/sandbox_email_interceptor.rb

Are emails sent from action mailers testable?

By default they are, but this can be turned off to help functional testing. Keeps an array of all the emails sent out through the Action Mailer with delivery_method :test. Most useful for unit and functional testing. An example would be adding the following to your appropriate config/environments/$RAILS_ENV.rb file:

How do I add attachments to Action Mailer?

Adding attachments has been simplified in Action Mailer 3.0. Pass the file name and content and Action Mailer and the Mail gem will automatically guess the mime_type, set the encoding and create the attachment.


2 Answers

We've found this list works pretty well for standard errors that you might want to retry on:

[ EOFError,
IOError,
TimeoutError,
Errno::ECONNRESET,
Errno::ECONNABORTED,
Errno::EPIPE,
Errno::ETIMEDOUT,
Net::SMTPAuthenticationError,
Net::SMTPServerBusy,
Net::SMTPSyntaxError,
Net::SMTPUnknownError,
OpenSSL::SSL::SSLError
]

Note that I didn't include Net::SMTPFatalError because it is often a permanent failure (like a blacklisted email address).

like image 57
David Avatar answered Sep 21 '22 19:09

David


Depends on your settings on how to send mails. If you're sending mails via smtp, ActionMailer uses Net::SMTP. There you will find the errors that could be raised.

If your application is configured to use sendmail, ActionMailer uses IO.

like image 41
pdu Avatar answered Sep 19 '22 19:09

pdu