Thank you for your reply. I have got it working following what you did.
I have a few questions however.
1) With the router, won't it stop all further routers from being executed?
There are a few routers below this one, which being an exim novice, I don't
quite understand what they do.
2) I would also like to know if there is much of a performance impact
re-calling the exim command via shell, and if this is the correct / most
optimized way to do this?
3) In your perl script you depend on the header "envelope-from". Is there a
guarantee that "envelope-from" is always set? From my experience, some mail
clients simply use the "from" header. Does exim always append the
"envelope-from" header for the stdin of the piped script?
My router and transport are as follows.
I have added a condition for return-path. I do not want to call the php for
bulk emails which are sent on the server as we occasionally send up to 30k
emails in a single hit. Bulk mailers typically set the return-path to handle
bounces.
synergy8_router:
driver = accept
transport = synergy8_transport
condition = ${if !def:header_return-path:}
no_more
With the transport, I have set the user to be that of the domain using a
lookup.
I have also added log_output to view what goes on inside the php module.
I have altered my command to include the user and the authenticated id via
command.
synergy8_transport:
driver = pipe
envelope_to_add
delivery_date_add
user = ${lookup{$domain}lsearch*{/etc/userdomains}{$value}}
group = mail
log_output = true
command = /usr/local/bin/php
/usr/lib/php/Synergy8/stable/components/community_members_correspondence/out
boundhandler.php ${lookup{$domain}lsearch*{/etc/userdomains}{$value}}
$authenticated_id
Once again, thank you *very much* for your help. It would have taken me
hours to work out the exim command in php and all of the router / transport
settings.
Cheers buddy,
Scott
-----Original Message-----
From: exim-users-bounces@??? [
mailto:exim-users-bounces@exim.org] On
Behalf Of Peter Velan
Sent: Friday, January 11, 2008 12:58 AM
To: exim-users@???
Subject: Re: [exim] FW: Piping all outgoing mail to a PHP script
am 10.01.2008 13:23 schrieb Scott McNaught:
> Hello,
>
> I am trying to pipe all outgoing SMTP mail to a php script. I have full
root
> access to the server, and changes can be made system wide via exim.conf.
>
> Has anyone got any examples that do anything similar to this?
I'm doing similar things, but with Perl.
After some ACL-fiddling, I'm getting the indicator: "do it with the
script" and my router ...
# special script router
#
rr_script:
driver = accept
transport = tt_script
condition = ${if match {$header_X-ACL-script:} {\N^(?i)xyz.*\N} }
no_more
... says: "use script transport", which looks like ...
# script transport
#
tt_script:
driver = pipe
envelope_to_add
delivery_date_add
user = (scriptowner)
group = (groutp_of_scriptowner)
command = /opt/mex/bin/mex.pl -log=y -eml=y -xpl=n - -
... now the perl script perfoms his dirty work and reinjects a modified
message into exim, with ...
# (last action of perl script)
#
# value of envelope from ------------------------------+
# set envelope from --------------------------------+ |
# single dot does terminate --------------------+ | |
# get recipients from input -----------------+ | | |
# value of $authenticated_id -----------+ | | | |
# set $authenticated_id -----------+ | | | | |
# accept message on stdin -----+ | | | | | |
# | | | | | | |
open MAIL, "| /usr/sbin/exim4 -bm -oMai xxx -t -oi -f '<x@???>'";
$mail->print( \*MAIL );
close MAIL;
Works great!
HTH,
Peter
--
## List details at
http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at
http://www.exim.org/
## Please use the Wiki with this list -
http://wiki.exim.org/