views:

50

answers:

1

I've been trying to send some test newsletter using my gmail account as smtp, but when i tried to send to multiple recipients - ['emai@[email protected], [email protected]'] - in this case the first email address is incorrect - it gives me an error 555 - 5.5.2 Syntax error and the process stops without passing through the next email addreses.

My question is: is there a possibility to bypass those kind of errors in order to skip the incorrect addresses and to continue sending the emails?

Regards.

+1  A: 

You can set ActionMailer to ignore delivery errors, but that's not really considered best practice in a production environment.

# environment.rb (or development/test etc)
ActionMailer::Base.raise_delivery_errors = false

If you don't have a lot of recipients, you could try looping through the array of addresses and sending an email for each one, rescuing a delivery error and adding a message to the log.

# Model
def send_emails(addresses)
  addresses.each do |address|
    begin
      YourMailer.deliver_method(email)
    rescue
      logger.error "Could not send email to #{email}" 
    end
  end
end
floyd
i've tried setting raise_delivery_errors=false without luck. I tend to think that the problem here is with smtp_tls stopping the process but i do not know for sure.Thanks for your time!
fk2blow
Did you try my second suggestion?
floyd