how do I forward an email to a perl script

Zauny

Valued Member
I am using a MySQL database to do my virtual_alias_maps. However I need to do forward email from one specific address to a perl script. I configured the path of the script as the destination of the alias I created by but it failed/returned an error. Please see below for the error...
"Dec 4 09:19:45 mail postfix/virtual[10422]: 992A4C5E085: to=</etc/postfix/scripts/network_alert.pl@speednet-wireless.com>, orig_to=<network_mobile@speednet-wireless.com>, relay=virtual, delay=0.61, delays=0.61/0/0/0.01, dsn=5.1.1, status=bounced (unknown user: "/etc/postfix/scripts/network_alert.pl@speednet-wireless.com")"
This is how I created the alias (I inserted a record into the mysql virtual alias table)...
mysql> insert into aliases (mail,destination) VALUES('network_mobile@speednet-wireless.com','/etc/postfix/scripts/network_alert.pl');

any ideas on how I can correct this would be greatly appreciated...
 

popowich

EQ Forum Admin
Staff member
Try piping to the script. Put a | in front of the script call.

|/etc/postfix/scripts/network_alert.pl

If that doesn't work I'll probably need to setup a test where I can tinker and get it right.
 

Zauny

Valued Member
Sadly still got an error...

root@mail:~# nice tail -f /var/log/mail.log |grep network_mobile
Dec 4 14:25:04 mail postfix/virtual[29987]: EBDDE534001: to=<|/etc/postfix/scripts/network_alert.pl@speednet-wireless.com>, orig_to=<network_mobile@speednet-wireless.com>, relay=virtual, delay=0.04, delays=0.03/0/0/0.01, dsn=5.1.1, status=bounced (unknown user: "|/etc/postfix/scripts/network_alert.pl@speednet-wireless.com")
 

Zauny

Valued Member
that's the exact URL I was looking at. my current virtual alias map is:
virtual_alias_maps = mysql:/etc/postfix/mysql_alias.cf
they are saying to modify/change to:
virtual_alias_maps = hash:/etc/postfix/redirect

will I lose my current mysql virtual map? how can I have both remember I only want this for one user...
 

popowich

EQ Forum Admin
Staff member
The new alias you're trying to add that calls the perl script is the only thing in your mysql?

Instead of putting it in mysql can you add it to the flat file like your other aliases?
 

Zauny

Valued Member
No, no all my users and aliases are in the mysql database. I will try virtual_alias_maps = hash:/etc/postfix/redirect, mysql:/etc/postfix/mysql_alias.cf. I will let you know how it works out...
 

Zauny

Valued Member
Sorry was busy with another project. But yes, I got it working. What I did was to modify my main.cf with
mydestination = localhost localhost.speednet-$mydomain
then created an aliases in mysql database
mysql> insert into aliases (mail,destination) VALUES('network_mobile@speednet-wireless.com','netmobile@localhost');
then create a local user (on the server)
then modify the alias
netmobile: "| /usr/bin/perl /etc/postfix/scripts/network_alert.pl"
then newaliases
the server postfix reload

thanks for your assistance...
 
Top