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?
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”.
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
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:
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.
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).
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With