Loading ...
Sorry, an error occurred while loading the content.
 

Re: Check Quota with external program

Expand Messages
  • Duane Hill
    ... [attributes removed] ... Within the Postfix downloadable distribution there is a greylist policy that can be used as a starting point:
    Message 1 of 9 , Jul 3, 2007
      On Tue, 3 Jul 2007 at 16:00 +0200, s.felici@... confabulated:

      > mouss ha scritto:
      >> Simone Felici wrote:
      >>>
      >>> Hi again,
      >>>
      >>> I've write a script in perl that can query the backend and the output of
      >>> the script is the using quota.
      >>> Now, the 'virtual_mailbox_limit_maps' will point to a sql db where all
      >>> quota limits for all mailboxes are set. Then, with
      >>> smtpd_recipient_restrictions I'll use this option: check_policy_service
      >>> unix:private/mailquota. 'mailquota' will be set up into a master.cf like
      >>> this:
      >>>
      >>> mailquota unix - n n - - spawn
      >>> user=nobody argv=/usr/bin/perl /etc/postfix/mailquota.pl
      >>>
      >>> But how can I pass to /etc/postfix/mailquota.pl the recipient argument?
      >>> The syntax to obtain the usage quota is /etc/postfix/mailquota.pl
      >>> <recipient-email>.
      >>> The output is the used quota of the <recipient-email> in bytes.
      >>
      >>
      >> you need to read the POLICY README document. but you certainly should use
      >> the policy server example distributed with postfix source code instead of
      >> reinventing the wheel.
      >>
      >>
      >
      >
      > I've read about the policy and have understood how it works.
      > Have someone an example on how collect the attr values sent from postfix to
      > the external program?
      >
      > These:
      >
      [attributes removed]
      >
      > I've no idea how to grep these infos into variable to use them into the
      > perl-script. The script works, 'cause if I set a static action="DUNNO",
      > "REJECT", "OK" or wathever, the answer is accepted from postfix and he accept
      > or reject the mails. My last problem is to pass the "send attr recipient =
      > bar@..." to a variable.
      >
      > A little help?
      >
      > I'm really new with perl too, btw someting is working ;)

      Within the Postfix downloadable distribution there is a greylist policy
      that can be used as a starting point:

      ../examples/smtpd-policy/greylist.pl

      It is the one I used myself when I first created a policy.

      If you are using the sample greylist.pl policy for an example, you don't
      need to pass the attributes to any variable. They are already contained
      within the variable:

      %attr

      The recipient attribute can be accessed within via:

      $attr("recipient"}

      Likewise, any of the other attributes can be accessed the same way:

      for the client IP : $attr{"client_address"}
      for the envelop sender : $attr{"sender"}
    • mouss
      ... Please take the time to read all the post instead of stopping at the first period. I said ... WITH POSTFIX SOURCE CODE .... ... The example policy server
      Message 2 of 9 , Jul 3, 2007
        Simone Felici wrote:
        >>
        >>
        >> you need to read the POLICY README document. but you certainly should
        >> use the policy server example distributed with postfix source code
        >> instead of reinventing the wheel.
        >>
        >>
        >
        >
        > I've read about the policy and have understood how it works.
        > Have someone an example on how collect the attr values sent from
        > postfix to the external program?

        Please take the time to read all the post instead of stopping at the
        first period. I said

        >> but you certainly should use the policy server example DISTRIBUTED
        WITH POSTFIX SOURCE CODE ....


        >
        > [snip]
        >
        > I've no idea how to grep these infos into variable to use them into
        > the perl-script. The script works, 'cause if I set a static
        > action="DUNNO", "REJECT", "OK" or wathever, the answer is accepted
        > from postfix and he accept or reject the mails. My last problem is to
        > pass the "send attr recipient = bar@..." to a variable.
        >
        > A little help?
        The example policy server will read the attributes into a hash table (in
        perl, this is used as this: $attr{"foo"} = "bar").
        >
        > I'm really new with perl too, btw someting is working ;)

        "Perl By Example" (http://affy.blogspot.com/p5be/index.htm) may help you...
      • Simone Felici
        ... Hi, I ve read the (graylist) examples and have helped me a lot. BTW there was a problem with the variables. Now I ve solved it. Thank s, bye Simon
        Message 3 of 9 , Jul 4, 2007
          mouss ha scritto:

          > Please take the time to read all the post instead of stopping at the
          > first period. I said
          >
          > >> but you certainly should use the policy server example DISTRIBUTED
          > WITH POSTFIX SOURCE CODE ....
          >
          >

          > "Perl By Example" (http://affy.blogspot.com/p5be/index.htm) may help you...
          >
          >
          >

          Hi,

          I've read the (graylist) examples and have helped me a lot. BTW there was a problem with the variables.
          Now I've solved it.

          Thank's, bye

          Simon
        Your message has been successfully submitted and would be delivered to recipients shortly.