Any ideas on how to do this....
/etc/valiases/domain.com
i know.... but does anyone know like what it should look like?
*: /home/user/path/to/script/script.php
is that what it should look like or am I way off? I haven't tried it yet, thought i'd ask first.
How to forward INCOMING email into a php script first?
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
You're way off. That valiases directory contains aliases for the actaul emails to be passed on to another address (email address, not script).
You need to use a transport protocol that will likely be referred to as "pipe" in your MTA. I don't know what MTA you're using but I know it's trivial in exim once you get your head around it. I've always found MTA's to be damn tricky things to configure (immensely moreso than apache or ftp) but you can do some fun things
What Mail Transfer Agent are you running?
You need to use a transport protocol that will likely be referred to as "pipe" in your MTA. I don't know what MTA you're using but I know it's trivial in exim once you get your head around it. I've always found MTA's to be damn tricky things to configure (immensely moreso than apache or ftp) but you can do some fun things
What Mail Transfer Agent are you running?
Cpanel/WHM, so Exim is the mail processor.....d11wtq wrote:You're way off. That valiases directory contains aliases for the actaul emails to be passed on to another address (email address, not script).
You need to use a transport protocol that will likely be referred to as "pipe" in your MTA. I don't know what MTA you're using but I know it's trivial in exim once you get your head around it. I've always found MTA's to be damn tricky things to configure (immensely moreso than apache or ftp) but you can do some fun things
What Mail Transfer Agent are you running?
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
OK if exim is the mail proccessor I'll show you how I currently use it to pass SPAM mail on my server to a PHP script to log it in a MySQL database.... you'll see the idea.Deseree wrote:Cpanel/WHM, so Exim is the mail processor.....d11wtq wrote:You're way off. That valiases directory contains aliases for the actaul emails to be passed on to another address (email address, not script).
You need to use a transport protocol that will likely be referred to as "pipe" in your MTA. I don't know what MTA you're using but I know it's trivial in exim once you get your head around it. I've always found MTA's to be damn tricky things to configure (immensely moreso than apache or ftp) but you can do some fun things
What Mail Transfer Agent are you running?
In exim.conf (usually /etc/exim/exim.conf but may vary):
Code: Select all
#This goes at the top of the config file... the path to system_filer.exim may vary
system_filter = /etc/exim/system_filter.exim
system_filter_pipe_transport = mysql_spamlog
#Down towards the bottom in the transports section
#Change the command to whatever your PHP script is (it needs a shebang in the script)
mysql_spamlog:
driver = pipe
command = /usr/local/bin/spam-mail-log
user = mail
group = mailCode: Select all
if
"${if def:header_X-Spam_flag: {there}}" is "there"
then
pipe "/usr/local/bin/spam-mail-log $sender_address $recipients $h_Subject: $message_body $h_X-Spam_report: $h_X-Spam_score: $message_id"
endifThe variables available to you are $h_Header-name, $message_body, $recipients, $sender_address (the full list is in the manual).
Now all that's left to do it to write your PHP script to pipe your mail to:
Code: Select all
#!/usr/local/bin/php
<?php
$conn = mysql_connect('localhost', 'user', 'pass');
mysql_select_db('spamassassin');
if (count($argv) < 8) die();
$copy = array();
foreach ($argv as $v) $copy[] = mysql_real_escape_string($v);
$pre_query = "select * from spamlog where message_id = '$copy[7]'";
$pre_result = mysql_result($pre_query);
if (mysql_num_rows($pre_result) > 0) die();
$query = "
insert into
spamlog (
sender,
recipient,
subject,
body,
report,
score,
message_id,
delivery_time)
values (
'$copy[1]',
'$copy[2]',
'$copy[3]',
'$copy[4]',
'$copy[5]',
'$copy[6]',
'$copy[7]',
now())";
mysql_query($query);
mysql_close();
?>If you get stuck just ask (on here)
heh, O M G. lol, that's pretty deep man.
I see how it works and all, here's the situation, maybe you can help think of a solution....
We've got 400 domains on the server, and right now we use catchall in valiases "*: one-main-email@gmail.com". I would like to setup some kind of free email forwarding service for PRIVATE users, nothing big. so I would like SELECT email's to go to my email, and others, to be routed else where.....no mysql database, heh, over loads the server quick with the amount of spiders and spam we get.
So after I pipe into the php script, how do I let the mail continue it's journey if it matches those seleect emails, and if it doesn't, it goes else where in the script, obviously an if else statment, and I can write that, so the real question is
what part of the script takes the email from the pipe and releases it for delivery?
I see how it works and all, here's the situation, maybe you can help think of a solution....
We've got 400 domains on the server, and right now we use catchall in valiases "*: one-main-email@gmail.com". I would like to setup some kind of free email forwarding service for PRIVATE users, nothing big. so I would like SELECT email's to go to my email, and others, to be routed else where.....no mysql database, heh, over loads the server quick with the amount of spiders and spam we get.
So after I pipe into the php script, how do I let the mail continue it's journey if it matches those seleect emails, and if it doesn't, it goes else where in the script, obviously an if else statment, and I can write that, so the real question is
what part of the script takes the email from the pipe and releases it for delivery?