how do I forward an email to a perl script

Discussion in 'Postfix' started by Zauny, Dec 4, 2013.

  1. Zauny

    Zauny Valued Member

    Joined:
    Sep 4, 2013
    Messages:
    34
    Likes Received:
    0
    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...
     


  2. popowich

    popowich EQ Forum Admin Staff Member

    Joined:
    Aug 12, 2008
    Messages:
    8,994
    Likes Received:
    120
    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.
     

  3. Zauny

    Zauny Valued Member

    Joined:
    Sep 4, 2013
    Messages:
    34
    Likes Received:
    0
    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")
     
  4. popowich

    popowich EQ Forum Admin Staff Member

    Joined:
    Aug 12, 2008
    Messages:
    8,994
    Likes Received:
    120
  5. Zauny

    Zauny Valued Member

    Joined:
    Sep 4, 2013
    Messages:
    34
    Likes Received:
    0
    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...
     
  6. popowich

    popowich EQ Forum Admin Staff Member

    Joined:
    Aug 12, 2008
    Messages:
    8,994
    Likes Received:
    120
    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?
     
  7. Zauny

    Zauny Valued Member

    Joined:
    Sep 4, 2013
    Messages:
    34
    Likes Received:
    0
    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...
     
  8. popowich

    popowich EQ Forum Admin Staff Member

    Joined:
    Aug 12, 2008
    Messages:
    8,994
    Likes Received:
    120
    Hi Zauny,

    Did you get this working?
     
  9. Zauny

    Zauny Valued Member

    Joined:
    Sep 4, 2013
    Messages:
    34
    Likes Received:
    0
    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...
     

Want to reply or ask your own question?

It only takes a minute to sign up (and it's free!). Click the orange sign up button to choose a username and then you can ask your own questions on the forum.
Loading...