Forum: Ruby on Rails piping bounced emails to rails script

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
267c254fe395122f506b6537d4ca797f?d=identicon&s=25 rcs (Guest)
on 2009-05-18 23:11
(Received via mailing list)
Hi all.  I have been banging my head against the wall for two days.
Hoping you can help; this isn't strictly a rails problem, but
something I'm encountering in trying to get rails and postfix to work
together.

I want to automate dealing with bounced messages, so I have bounced
emails bounce back to "bounces@mydomain.com."

I want to do this in my /etc/aliases file:

bounces:  | "RAILS_ENV=production /usr/bin/ruby /home/rails/appname/
current/script/runner 'BouncedEmail.receive(STDIN.read)'

so that I can process the email in rails.

But it's not working, and I don't know what I'm doing wrong, so I
tried the following:
If I have "bounces: root", then the email gets properly directed to
root's email folder fine, so the alias stuff should be working, but
piping to a trivial command doesn't seem to work at all.  If I do

bounces: | "echo 'hi' > /tmp/test"

I see nothing when I send an email to bounces.

Anybody have any ideas?
Bee69cfed999cd13e3bff73d472a39ee?d=identicon&s=25 Hassan Schroeder (Guest)
on 2009-05-18 23:37
(Received via mailing list)
On Mon, May 18, 2009 at 1:38 PM, rcs <rsarvis@gmail.com> wrote:

> I want to automate dealing with bounced messages, so I have bounced
> emails bounce back to "bounces@mydomain.com."
>
> I want to do this in my /etc/aliases file:
>
> bounces:  | "RAILS_ENV=production /usr/bin/ruby /home/rails/appname/
> current/script/runner 'BouncedEmail.receive(STDIN.read)'

I would think that would be iffy just because of the startup time.

Personally I would create an actual "bounces" user, let the mails go
to that account normally, and run a cron job to process the mail file.

YMMV!
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
Aad37b5f7116c8d1f547d23b37566032?d=identicon&s=25 Greg Donald (destiney)
on 2009-05-18 23:41
(Received via mailing list)
On Mon, May 18, 2009 at 3:38 PM, rcs <rsarvis@gmail.com> wrote:
> I want to do this in my /etc/aliases file:
>
> bounces:  | "RAILS_ENV=production /usr/bin/ruby /home/rails/appname/
> current/script/runner 'BouncedEmail.receive(STDIN.read)'

You need to use procmail, and put something almost exactly like that
in your .procmailrc.

http://userpages.umbc.edu/~ian/procmail.html



--
Greg Donald
http://destiney.com/
6883e5ef03484d4fcef507d7b4f1d243?d=identicon&s=25 Matt Jones (Guest)
on 2009-05-19 16:40
(Received via mailing list)
Two things - the | character should be inside the quotes. And, take a
look at this:
http://forum.symfony-project.org/index.php/m/26063/

for discussion on getting a similar setup running (postfix needs to be
delivering as a user other than nobody).

--Matt Jones
D9b34957aad023fb316d9a505f0baff0?d=identicon&s=25 vicky m. (vicky_m)
on 2011-11-19 18:16
hello!

Can you help me out in implementing bouncing??

Regards,
Harish
(erharish43.malik@gmail.com)


rcs wrote in post #817505:
> Hi all.  I have been banging my head against the wall for two days.
> Hoping you can help; this isn't strictly a rails problem, but
> something I'm encountering in trying to get rails and postfix to work
> together.
>
> I want to automate dealing with bounced messages, so I have bounced
> emails bounce back to "bounces@mydomain.com."
>
> I want to do this in my /etc/aliases file:
>
> bounces:  | "RAILS_ENV=production /usr/bin/ruby /home/rails/appname/
> current/script/runner 'BouncedEmail.receive(STDIN.read)'
>
> so that I can process the email in rails.
>
> But it's not working, and I don't know what I'm doing wrong, so I
> tried the following:
> If I have "bounces: root", then the email gets properly directed to
> root's email folder fine, so the alias stuff should be working, but
> piping to a trivial command doesn't seem to work at all.  If I do
>
> bounces: | "echo 'hi' > /tmp/test"
>
> I see nothing when I send an email to bounces.
>
> Anybody have any ideas?
This topic is locked and can not be replied to.