postfix+perl script

Discussion in 'Server Operation' started by robin, Jul 24, 2006.

  1. robin

    robin New Member

    I have a domain which its fqdn is mail.robin.com
    pointing to this i have added a subdomain rep.robin.com

    the mx record has been set up with isp for rep.robin.com

    also rep.robin.com has been added to the
    mydestination line in main.cf in postfix and to hosts file in
    /etc/hosts

    what i have done is set up postfix to accept mail to '[email protected]'
    and deliver them via pipe to the command "repserver -d foo"

    its the "deliver them via pipe to the command repserver -d foo"
    than i do not know how to set up.?

    but my thinking is:

    in /etc/aliases someusername: | repserver.pl(path to it)
    run newaliases


    no need to run repserver.pl -d $someusername
    because script gets called automattically?








    (repserver is a perl script)

    rob
     
    Last edited: Jul 25, 2006
  2. falko

    falko Super Moderator ISPConfig Developer

    Should work. Did you test it?
    Alternatively you can put your pipe into a .forward file in the user's homedir. the .forward file must be owned by that user.
     
  3. robin

    robin New Member

    perl script+postfix

    did i test it? no not yet.

    the script it i were to print it out on paper would use 30 A4 size pages!!
    it will create a data base so people can create email addresses and use them at
    rep.robin.com

    can you please give me an example of how the command might look
    if i were to use a .foward file in say username rob's homedir?

    something like this in say rob's homedir

    echo '"| /path/to/repserver.pl"' >>~/.forward?

    the comand so that rob has ownership is what ,chmod rob rob .foward?







    robin
     
    Last edited: Jul 26, 2006
  4. falko

    falko Super Moderator ISPConfig Developer

    Yes.

    .forward is executed as the user to whom the directory belongs (it's the user's homedir), so there's no need to specify a user.
     
  5. robin

    robin New Member

    yes thats correct it is there but inside the file .forward we have:

    "|/usr/bin/procmail -f-"

    is it still ok to issue the comand below?

    echo '"| /path/to/repserver.pl"' >>~/.forward

    OK i looks fine but I need to rethink

    first option was:
    /etc/aliases someusername: | repserver.pl someusername
    (and newalias)

    second option was:
    "|/path/to/repserver.pl someuser

    in the .forward. I must remember the repserver script is able to add new users when they complete the registration process, so I would have to modify the script in order to run one of these two commands after a successful registration. This is messy. I'm quite sure there is a cleaner way to ask postfix to pipe every mails received for ${foo}@${nymdomain} to "repserver.pl -d $foo".?










    robin
     
    Last edited: Jul 27, 2006
  6. falko

    falko Super Moderator ISPConfig Developer

    You will then lose your procmail recipes, i.e., they won't be executed anymore, so I guess it's better to go the /etc/aliases way.
     
  7. robin

    robin New Member

    yes i would like to do you suggested but if you read the paragrapth in my last post which reads:

    in the .forward. I must remember the repserver script is able to add new users when they complete the registration process, so I would have to modify the script in order to run one of these two commands after a successful registration. This is messy. I'm quite sure there is a cleaner way to ask postfix to pipe every mails received for ${foo}@${nymdomain} to "repserver.pl -d $foo".?


    two
    commands means i cannot use .forward or /etc/aliases


    robin

    ps how about use procmail like this:

    | repserver.pl $LOGNAME

    but not sure in which file to place this command after what you said in post 6?
     
    Last edited: Jul 28, 2006
  8. falko

    falko Super Moderator ISPConfig Developer

    You could create a filter in /etc/postfix/master.cf for your script.
     
  9. robin

    robin New Member

    postfix/script

    create a filter, maybe.

    I have a perhaps simpler idea but i am not sure how to set it up perhaps you could point me in the direction by way of howto's or other information.

    here we go:
    Make rep.robin.net a virtual alias domain, with a wildcard. Point that virtual alias to some local user ([email protected] or whatever). Have *that* user deliver to a pipe, via /etc/aliases.

    or another way to say the same thing:


    in some local domain on that server, add an alias for a user, say, "repserver", that pipes to the program.
    Then add rep.robin.net as a virtual alias domain, and add a wildcard virtual alias that points to [email protected]



    robin
     
    Last edited: Jul 28, 2006
  10. falko

    falko Super Moderator ISPConfig Developer

    Hm, I think a Postfix filter is easier to implement...
     
  11. robin

    robin New Member

    >Hm, I think a Postfix filter is easier to implement...

    ok thanks falko please point me to a howo or some info that might help please.

    ok i think we have to two things?
    1 define a content_filter parameter for the proper smtpd in the master.cf file

    2 Define the tranport in the master.cf file.

    here is my master.cf
    it does not come out like the one i pasted but i think it will be ok

    -------------------------------------------------------------------------------------------------------------------------------------------
    #
    # Postfix master process configuration file. For details on the format
    # of the file, see the Postfix master(5) manual page.
    #
    # ==========================================================================
    # service type private unpriv chroot wakeup maxproc command + args
    # (yes) (yes) (yes) (never) (100)
    # ==========================================================================
    smtp inet n - - - - smtpd
    #submission inet n - - - - smtpd
    # -o smtpd_etrn_restrictions=reject
    # -o smtpd_client_restrictions=permit_sasl_authenticated,reject
    #smtps inet n - - - - smtpd
    # -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes
    #submission inet n - - - - smtpd
    # -o smtpd_etrn_restrictions=reject
    # -o smtpd_enforce_tls=yes -o smtpd_sasl_auth_enable=yes
    #628 inet n - - - - qmqpd
    pickup fifo n - - 60 1 pickup
    cleanup unix n - - - 0 cleanup
    qmgr fifo n - n 300 1 qmgr
    #qmgr fifo n - - 300 1 oqmgr
    tlsmgr unix - - - 1000? 1 tlsmgr
    rewrite unix - - - - - trivial-rewrite
    bounce unix - - - - 0 bounce
    defer unix - - - - 0 bounce
    trace unix - - - - 0 bounce
    verify unix - - - - 1 verify
    flush unix n - - 1000? 0 flush
    proxymap unix - - n - - proxymap
    smtp unix - - - - - smtp
    # When relaying mail as backup MX, disable fallback_relay to avoid MX loops
    relay unix - - - - - smtp
    -o fallback_relay=
    # -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
    showq unix n - - - - showq
    error unix - - - - - error
    discard unix - - - - - discard
    local unix - n n - - local
    virtual unix - n n - - virtual
    lmtp unix - - - - - lmtp
    anvil unix - - - - 1 anvil
    scache unix - - - - 1 scache
    #
    # ====================================================================
    # Interfaces to non-Postfix software. Be sure to examine the manual
    # pages of the non-Postfix software to find out what options it wants.
    #
    # Many of the following services use the Postfix pipe(8) delivery
    # agent. See the pipe(8) man page for information about ${recipient}
    # and other message envelope options.
    # ====================================================================
    #
    # maildrop. See the Postfix MAILDROP_README file for details.
    # Also specify in main.cf: maildrop_destination_recipient_limit=1
    #
    maildrop unix - n n - - pipe
    flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
    #
    # See the Postfix UUCP_README file for configuration details.
    #
    uucp unix - n n - - pipe
    flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
    #
    # Other external delivery methods.
    #
    ifmail unix - n n - - pipe
    flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
    bsmtp unix - n n - - pipe
    flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
    scalemail-backend unix - n n - 2 pipe
    flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
    mailman unix - n n - - pipe
    flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
    ${nexthop} ${user}
     
    Last edited: Jul 29, 2006
  12. falko

    falko Super Moderator ISPConfig Developer

  13. robin

    robin New Member

    thanks for the url's

    please indicate which paragraph's in readme below are specific to creating a filter in /etc/postfixmaster.cf for my script. are we concerned with the simple filter setup?


    http://www.postfix.org/FILTER_README.html

    robin
     
    Last edited: Jul 31, 2006
  14. falko

    falko Super Moderator ISPConfig Developer

    A simple content filter should do. :)
     
  15. robin

    robin New Member

    postfix/filter

    how does this look:

    --------------------------------------------------------------

    in /etc/postfix/main.cf

    relay_domians = rep.robin.net



    etc/postfix/master.cf

    repserver unix - n n - - pipe
    flags=FR user=repserver argv=/home/repserver/repserv -d $recipient

    -------------------------------------------------------------------------------------------------

    (a) paste above line into main.cf and two lines at bottom of master.cf file?
    (b ) create a user with adduser called repserver make a directory mkdir: repserver and with touch a file
    called repserv and i assume place the actual perl script reserver.pl in the repserver directory?
    (c ) In master.cf there is a line see below or post 11(does this affect the relay_domains line in main.cf)?

    relay unix - - - - - smtp
    -o fallback_relay=



    robin
     
    Last edited: Aug 1, 2006
  16. falko

    falko Super Moderator ISPConfig Developer

    I post an example how I once configured a simple filter in Postfix. In master.cf, I changed the first line to

    Code:
    smtp inet n - y - - smtpd -o content_filter=filter:dummy
    and then at the end of master.cf, I created the filter called filter:

    Code:
    filter unix - n n - - pipe flags=Rq user=filter argv=/usr/local/anomy/filter.sh -f ${sender} -- ${recipient}
     
  17. robin

    robin New Member

    postfix/perl script

    ok thanks for your post falko(see pm)

    ok i think i know what to put at the end of master.cf now it will be ( filter is called repserver)


    repserver unix - n n - - pipe flags=FR user=repserver
    argv=/home/repserver/repserv -d $recipient



    (this line above should be on one line like your little box in the last post
    but i think you get the idea)

    so we have the bottom part of the master.cf I am not sure what the top
    part would look like?
     
    Last edited: Aug 1, 2006
  18. falko

    falko Super Moderator ISPConfig Developer

    Try this:

    Code:
    smtp inet n - y - - smtpd -o content_filter=repserver:dummy
     
  19. robin

    robin New Member

    thanks for making this content_filter clear

    Just to put things into some sort of order

    TODO:


    place the the line in /etc/postfix/main.cf

    relay_domains = rep.robin.net

    place the lines in /etc/postfix/master.cf

    top
    smtp inet n - y - - smtpd -o content_filter=repserver:dummy (why dummy)?

    bottom
    repserver unix - n n - - pipe flags=FR user=repserver argv=/home/repserver/repserv -d $recipient

    finish?

    THINGS NOT TO DO

    create a user with adduser called repserver make a directory mkdir: repserver and with touch a file called repserv and i assume place the actual perl script reserver.pl in the repserver directory
    In master.cf there is a line see below or post 11(does this affect the relay_domains line in main.cf)?

    relay unix - - - - - smtp
    -o fallback_relay=


    robin
     
  20. falko

    falko Super Moderator ISPConfig Developer

Share This Page