postfix+perl script

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

  1. robin

    robin New Member

    thanks for explaination of "dummy" reference.

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

    Does the bold area mean 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

    robin
     
    Last edited: Aug 4, 2006
  2. falko

    falko Super Moderator Howtoforge Staff

    argv must contain the full path to your Perl script (including your Perl script), e.g. like this:

    argv=/home/repserver/repserv/repserver.pl
     
  3. robin

    robin New Member

    postfix /script

    in /etc/postfix/main.cf

    relay_domians = rep.robin.net

    I was just wondering if the "relay" entry i have in the /etc/master.cf which is:


    # When relaying mail as backup MX, disable fallback_relay to avoid MX loops
    relay unix - - - - - smtp
    -o fallback_relay=


    has any effect with above relay_domains line in main.cf?

    at the moment rep.robin.net points to the MX record mail.robin.net with a weight of 10


    robin
     
    Last edited: Aug 4, 2006
  4. falko

    falko Super Moderator Howtoforge Staff

    I don't think so...
     
  5. robin

    robin New Member

    Below is the final /etc/postfix/master.cf with the 2 lines inserted in bold.
    is this exactly how it should look?




    #
    # 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
    smtp inet n - y - - smtpd -o content_filter=repserver:dummy
    #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}
    repserver unix - n n - - pipe flags=FR user=repserver argv=/home/repserver/repserv/repserver.pl -d $recipient
     
    Last edited: Aug 14, 2006
  6. falko

    falko Super Moderator Howtoforge Staff

    You need just this line:

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

    robin New Member

    falko wrote

    "You need just this line:" see last post

    ok thanks for presenting the line correctly.

    then where does this line go?

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

    I thought it was a the bottom of the master.cf file?

    robin
     
  8. falko

    falko Super Moderator Howtoforge Staff

    Yes, just one smtp line. You still need the repserver filter line.

    Yes, at the bottom.
     
  9. robin

    robin New Member

    falko many thanks for your assistance on this thread.

    In a pervious post you said:

    >argv must contain the full path to your Perl script (including your Perl script), e.g. >like this:

    >argv=/home/repserver/repserv/repserver.pl

    i have created the dir as you see below all i need do now is add repserver.pl
    and do chmod 755 repserver.pl stop postfix then reload config hope it works!!


    total 612
    drwxr-xr-x 7 repserver repserver 4096 2006-08-07 21:22 .
    drwxr-xr-x 5 root root 4096 2006-08-05 13:29 ..
    -rw------- 1 repserver repserver 14 2006-08-07 21:21 .bash_history
    -rw-r--r-- 1 repserver repserver 220 2006-08-05 13:29 .bash_logout
    -rw-r--r-- 1 repserver repserver 414 2006-08-05 13:29 .bash_profile
    -rw-r--r-- 1 repserver repserver 2227 2006-08-05 13:29 .bashrc
    -rw------- 1 repserver repserver 26 2006-08-07 21:18 .dmrc
    drwx------ 2 repserver repserver 4096 2006-08-07 21:22 .fluxbox
    -rw-r--r-- 1 repserver repserver 561122 2006-08-07 21:18 .fonts.cache-1
    drwx------ 2 repserver repserver 4096 2006-08-07 21:18 .gconf
    drwx------ 2 repserver repserver 4096 2006-08-07 21:22 .gconfd
    drwx------ 3 repserver repserver 4096 2006-08-07 21:18 .mozilla
    drwxr-xr-x 2 repserver repserver 4096 2006-08-07 21:21 repserv
    -rw-r--r-- 1 repserver repserver 9063 2006-08-07 21:21 .xsession-errors

    -----------------------------------------------
    update
    line in main.cf and two lines in master.cf, ran script some errors, but main concern is when sending mail with the the new lines in master.cf and main.cf mail sent from postmaster/admin comes back. not sure why.
    should /home/repserver have root privalgies? ran script from /home/robin
    see returned mail below

    -----------------------------------------
    From MAILER-DAEMON Mon Aug 14 23:12:27 2006
    Return-Path: <>
    X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on
    mail.example.net
    X-Spam-Level:
    X-Spam-Status: No, score=-0.0 required=5.0 tests=NO_RELAYS autolearn=ham
    version=3.1
    X-Original-To: [email protected]
    Delivered-To: [email protected]
    Received: by mail.example.net (Postfix)
    id 9034D3907ED; Mon, 14 Aug 2006 23:12:27 +0100 (BST)
    Date: Mon, 14 Aug 2006 23:12:27 +0100 (BST)
    From: [email protected] (Mail Delivery System)
    Subject: Undelivered Mail Returned to Sender
    To: [email protected]
    MIME-Version: 1.0
    Content-Type: multipart/report; report-type=delivery-status;
    boundary="B9E9C3907EA.1155593547/mail.example.net"
    Message-Id: <[email protected]>

    This is a MIME-encapsulated message.

    --B9E9C3907EA.1155593547/mail.example.net
    Content-Description: Notification
    Content-Type: text/plain
    This is the Postfix program at host mail.example.net.
    I'm sorry to have to inform you that your message could not
    be delivered to one or more recipients. It's attached below.

    For further assistance, please send mail to <postmaster>

    If you do so, please include this problem report. You can
    delete your own text from the attached returned message.

    The postfix program
    <[email protected]>: Command died with status 9:
    "/home/repserver/repserv/repserver.pl". Command output: "my"
    variable $n
    masks earlier declaration in same scope at
    /home/repserver/repserv/repserver.pl line 624. syntax error at
    /home/repserver/repserv/repserver.pl line 83, near "bin_ _ my "
    Global
    symbol "$MAXLINES" requires explicit package name at
    /home/repserver/repserv/nymserver.pl line 83. syntax error at
    /home/repserver/repserv/repserver.pl line 92, near "good_
    # for. We default to seven days._ _ # Flags in user ".dat" file:_
    my "
    Global symbol "$FL_ENCRECV" requires explicit package name at
    /home/repserver/repserv/repserver.pl line 92. syntax error at
    /home/repserver/repserv/repserver.pl line 120, near "messaged_ my "
    Global
    symbol "$pgppid" requires explicit package name at
    /home/repserver/repserv/repserver.pl line 120. Global symbol
    "$pgppid"
    requires explicit package name at
    /home/repserver/repserv/repserver.pl line
    372. Global symbol "$pgppid" requires explicit package name at
    /home/repserver/repserv/repserver.pl line 372. Global symbol
    "$PASSPHRASE"
    requires explicit package name at
    /home/repserver/repserv/repserver.pl line
    519. Global symbol "$FL_ENCRECV" requires explicit package name at
    /home/repserver/repserv/repserver.pl line 660. Global symbol
    "$PASSPHRASE"
    requires explicit package name at
    /home/repserver/repserv/repserver.pl line
    696. syntax error at /home/repserver/repserv/repserver.pl line 931,
    near ")
    {" /home/repserver/repserv/repserver.pl has too many errors.




    --B9E9C3907EA.1155593547/mail.example.net
    Content-Description: Delivery report
    Content-Type: message/delivery-status

    Reporting-MTA: dns; mail.example.net
    X-Postfix-Queue-ID: B9E9C3907EA
    X-Postfix-Sender: rfc822; [email protected]
    --B9E9C3907EA.1155593547/mail.example.net
    Content-Description: Undelivered Message
    Content-Type: message/rfc822








    robin
     
    Last edited: Aug 15, 2006
  10. falko

    falko Super Moderator Howtoforge Staff

    Your script is called, so that is fine, but there seem to be errors in your script. Please try to debug it.
    Does this happen only when you send from postmaster/admin, or also when you send from other accounts?
     
  11. robin

    robin New Member

    i have not tried other accounts.

    I was sending a mail to a friend because I ran the script
    from the comand line not in repserver but in another accont as repserver does not have root privlages.?

    The mail i was sending from admin was just to tell my friend that I found some errors in the script and thats when the mail came back I have now taken the lines out of
    postfix untill I can fix the bugs in repserver.pl.





    robin
     
    Last edited: Aug 15, 2006

Share This Page