Hi,
I am developing a rails 3 application. I want to use a interceptor before delivering emails. If a conditions meets, I want to stop the email. How do I do that?
Thanks.
Sam
Hi,
I am developing a rails 3 application. I want to use a interceptor before delivering emails. If a conditions meets, I want to stop the email. How do I do that?
Thanks.
Sam
When you say 'delivering' emails do you mean 'sending'?. Is it the rails app that is sending the email? If so how is it initiating the send. Can you not just test the conditions before sending?
Colin
Hi,
I am developing a rails 3 application.
I want to use a interceptor before delivering emails.
If a conditions meets, I want to stop the email.
How do I do that?
Have a look at the railscast for actionmailer in rails 3. The last part of the video is about intercepting
the emails so it gets sent to the address you specify in your config.
Sam Kong wrote in post #984511:
Hi,
I am developing a rails 3 application. I want to use a interceptor before delivering emails. If a conditions meets, I want to stop the email. How do I do that?
Thanks.
Sam
Sam, did you get a solution with an interceptor? I tried returning false but the email is still delivered.
Sam Kong wrote in post #984511:
Hi,
I am developing a rails 3 application. I want to use a interceptor before delivering emails. If a conditions meets, I want to stop the email. How do I do that?
Thanks.
Sam
You can throw an exception in the interceptor.
I had the same problem, and stumbled upon this while reading the source code:
class MailInterceptor def self.delivering_email(email) email.perform_deliveries= false end end
@jaden_c, I tried the "perform_deliveries = false" in my interceptor but the message still sends.
class CANSPAMInterceptor def self.delivering_email(message)
......
message.perform_deliveries = false if message.to.size == 0 end end
Is there something else I need to know?
kt