Limit the number of daily emails sent per user or domain

  • Nálam ez már működik...végre
    install: deb7,deb8
    Installation



    1. Install a DBMS (MySQL for instance), cluebringer, and cluebringer-webui :
    apt-get install mysql-server cluebringer cluebringer-mysql cluebringer-webui



    Note that cluebringer-webui will install apache as a dependency if you don’t already have a webserver.



    2.Set-up the Cluebringer databaseGet the initial database schema that correspond to your DBMS, for instance mysql :



    cp /usr/share/doc/postfix-cluebringer/database/policyd-db.mysql.gz ~/ && gunzip ~/policyd-db.mysql.gz



    3.Create the database, and populate it with the initial dump :

    # cd ~/ && mysql -u root -pmysql> CREATE DATABASE cluebringer;
    mysql> CREATE USER 'cluebringer'@'localhost' IDENTIFIED BY 'mypassword';
    mysql> GRANT ALL PRIVILEGES ON cluebringer.* TO 'cluebringer'@'localhost';
    mysql> \. policyd-db.mysql
    mysql> quit
    mysql> Bye
    Note that on Debian I had to modify the dump to make it work, TYPE=InnoDB was rejected by MySQL as an invalid syntax.Editors db.mysql you replace the Policy-TYPE = InnoDB -> ENGINE = InnoDB



    4.Configure CluebringerAdd your DBMS credentials to the file /etc/cluebringer/cluebringer.conf



    DSN=DBI:mysql:dbname=cluebringer;host=localhost
    DB_Type=mysql
    DB_Host=localhost
    DB_Port=3306
    DB_Name=cluebringer
    Username=cluebringer
    Password=mypassword



    service postfix-cluebringer start



    5.Configure Cluebringer webuiConfigure the file /etc/cluebringer/cluebringer-webui.conf with your DBMS credentials :



    <?php$DB_DSN="mysql:host=localhost;dbname=cluebringer";$DB_USER="cluebringer";$DB_PASS="mypassword";



    Cluebringer Webui needs a web server to run. Copy the sample configuration from the package documentation :



    cp /usr/share/doc/postfix-cluebringer-webui/examples/httpd/cluebringer-httpd.conf /etc/apache2/conf.d/




    Restart Apache :



    service apache2 restart



    6.Configure Cluebringer using its webuiAdd a policy




    Under Policies -> Main, disable Test policy (select policy and choose Action -> Change and switch Disabled to yes, validate)
    Add a new policy : Action -> Add, give it a name and a description
    Activate your new policy : select policy and choose Action -> Change (switch Disabled to no)
    Add a new member to your policy : select it and choose Action -> Members, and then Action -> Add. Specify any as source and any as destination.
    Go back to your policy, choose Action -> Members, and the select your member, do Action -> Change, and activate your new member (switch Disabled tono).



    Add a quota
    Under Quotas -> Configure, disable Test quotas.
    Add a new quota : Choose Action -> Add

    • Name : whatever you want
    • Track : user@domain
    • Period (seconds) : 3600
    • Link to policy : specify the policy you created here
    • Verdict : Defer
    • Data : set a custom error message here
    • Comment : whatever you want

    Activate your quota : switch Disabled to no.
    Add a limit to your quota : select your quota, and choose Action -> Limits, then Action -> Add.


    • Type : MessageCount
    • Counter Limit : 200

    Activate your limit : switch Disabled to no.



    7.Configure Postfix to call Cluebringer for each mail sent



    Open /etc/postfix/main.cf and locate the line smtpd_sender_restrictions.
    Add check_policy_service inet:127.0.0.1:10031 at the end of the line, for instance :



    smtpd_sender_restrictions = check_sender_access mysql:/etc/postfix/mysql-virtual_sender.cf, check_policy_service inet:127.0.0.1:10031

    f the line does not exists, simply add it.
    Don’t forget to restart Postfix :
    service postfix restart



    8.Check your configYou can now send some mails to see what happens. To check if these mails are passed to Cluebringer, connect to MySQL as thecluebringer user :



    # mysql -u cluebringer -p cluebringer



    And execute the query :



    mysql> SELECT * FROM quotas_tracking;



    You should see the value LastUpdate and Counter updating when sending a mail. Note that sending to multiple recipient will count like multiple mails were sent.Cluebringer versions prior to 2.1.x does not support IPv6, your customers won’t be able to send any mail if they have an IPv6 connection.Unfortunately, the Debian stable version (wheezy) provides Cluebringer 2.0.10 within its repositories, as well as the experimental release of Debian (sid). As an alternative, you should consider installing the 2.1.x experimental Cluebringer from official website instead of Debian packages from repositories.

    Dankó István

  • Köszi István, ez nagyon hasznos leírás.
    Még nem próbáltam ki, de érik a dolog. :)

    i-MSCP 1.5.3
    Plugins (latest version): ClamAV, CronJobs, DomainAutoApproval, LetsEncrypt, OpenDKIM, PanelRedirect, PhpSwitcher, PolicydSPF, Postgrey, RecaptchaPMA, RoundcubePlugins, SpamAssasin, WHMCS

  • Szia Dylan !
    Örülök hogy hasznosnak találtad te is,nagyon rég óta kerestem megoldást erre a problémára ,most már 2 szerveren is megy,és tökéletesen működik :)
    A hétvégén integrálom a harmadikra is.

    Dankó István

  • Úgy néz ki, hogy most érett meg a dolog, hogy ezt bevezessük, mert spamlistára kerültünk egy feltört fiók miatt.


    Egy kérdés:
    Ha jól látom, ez az óránként kiküldött leveleket limitálja?
    A php -val küldött leveleket is számolja, vagy csak egy adott levél fiókból küldött leveleket?
    Össze lehetne e hozni vajon ebből egy plugint?
    A hivatalos hírlevél küldő ügyfeleimnek akarnék egy olyan felületet csinálni, ahol egyedileg eltérhetnek a megadott limittől, max 1 napra, hogy pl egy webshop tudjon levelet küldeni a feliratkozott ügyfeleinek.

    i-MSCP 1.5.3
    Plugins (latest version): ClamAV, CronJobs, DomainAutoApproval, LetsEncrypt, OpenDKIM, PanelRedirect, PhpSwitcher, PolicydSPF, Postgrey, RecaptchaPMA, RoundcubePlugins, SpamAssasin, WHMCS

  • Szia Dylan ,


    Nálam a php alapu email küldés smtp hitelesítéshez van kötve minden usernél.
    Szerencsére a listában szereplő szürök müködnek rendesen a bejövö korlát a kimenő korlát stb..


    Tegnap ki próbáltam,a kérdésedre a válasz,igen számolja.
    Remélem hasznát tudod venni a leírásnak te is.


    plusz captcha van elhelyezve.

    Dankó István

  • Sziasztok!


    Most találtam meg ezt a topicot, nagyon jó, hogy ez a probléma is megoldódott, hamarosan bevezetem én is.
    Köszi!

  • Sziasztok! Régi motoros vagyok, örülök, hogy még mindig aktív a magyar topik! Sajnos nemrég Decemberében egy titokzatos oknál fogva bannoltak, ill töröltek az oldalról. Amire a válasz csak annyi volt hogy "hát biztosan jó oka volt rá" de megmondani nem tudta miért történt. Ennyire szeretik a magyarokat :) Egyébként csodálattal látom mennyit foglalkoztok ezzel a motorral. Nemkülömben én is így vagyok vele, és pár év után az 1.1 óta úgynéz ki tényleg komolyabban használható "lesz", mert azért még van mit tenni venni.

  • Szia,


    Ez azt jelenti, hogy a PHP mail le van tíltva? Csak smtp -vel megy ?