How do I stop email from being delivered in the interceptor?

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

On 28 February 2011 18:44, Sam K. [email protected] wrote:

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?

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

On Tue, Mar 1, 2011 at 2:44 AM, Sam K. [email protected] wrote:

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.

To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.

Sam K. 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.

Sam K. 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.

@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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs