[Exim] Tracking email in php (and possibly other wrapper pro…

Etusivu
Poista viesti
Vastaa
Lähettäjä: Eli
Päiväys:  
Vastaanottaja: exim-users
Aihe: [Exim] Tracking email in php (and possibly other wrapper programs)
I'm not sure if this is going to be of any use to anyone on this list, but I
figured I'd post it anyways since it took me quite a bit of fiddling to get
this working.

I've been searching for a way to track emails that are sent from PHP. PHP
on my webservers runs as an Apache module, so it can't be tracked like stuff
that runs with suexec can be. I also didn't want to set the trusted_users
setting to include the user that Apache runs as (so that I could use the
-oMas setting to specify something that could be logged) since that could
impose a security risk if I didn't pay close attention.

So, my final solution to this was actually to use my environment variable
patch (http://nutbar.chemlab.org/downloads/other/env-exim-4.30.patch)! I
put this in my acl_not_smtp ACL:

        warn message    = X-Domain: $env_SERVER_NAME


Then in the Apache virtual host section for the website to track, I put
this:

        php_admin_value sendmail_path "SERVER_NAME='domainname.com'
/usr/sbin/sendmail -t -i"


This sets the environment variable SERVER_NAME to the value specified so
that it can be accessed in the ACL stage when exim is sending the email
locally.

I didn't want to use the -f option in exim because my users need to be able
to specify alternate From: addresses since the webserver has no knowledge of
the mail user setup (so I wouldn't know what From: addresses were valid or
not, so I just allow anything).

The upside is so far it seems to work, and users can't bypass it. The
downside is that I don't know how reliable using an environment variable is
(I don't know if I can be sure that SERVER_NAME will be there in all cases).
Either way, I am going to implement it in production and I don't forsee any
issues.

So for what it's worth, if anyone's looking for something like this for
their setup, this may be a solution for you.

Eli.