Postfix Mail limit per hours?

Discussion in 'ISPConfig 3 Priority Support' started by ktownmods, Feb 27, 2020.

  1. ktownmods

    ktownmods Member

    Hey, is there a maillimit for sending on Postfix with ISPConfig?

    because i have to send soon mails to 54k users.
     
  2. Th0m

    Th0m ISPConfig Developer ISPConfig Developer

    Not 100% sure, but I think ISPConfig doesn't limit this in Postfix - however, I don't think you want to send the same mail to 54000 people, using your own mailservers. I'd recommend a service like Sendy instead.
     
  3. ktownmods

    ktownmods Member

    Why i should use an mail service and not my own?
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    Because your mail server will probably get blocked and blacklisted within minutes by all larger mail systems after you started sending.
     
  5. Th0m

    Th0m ISPConfig Developer ISPConfig Developer

    Take a look at this article: https://support.google.com/a/answer/81126?hl=en
    One of the important things is the reputation, which is something you have to slowly build up.
    Also, you will need newsletter software because it adds things like a unsubscribe link.

    Sendy is very cheap. You run the software yourself and it uses Amazon SES SMTP servers to send email for your domain. These mailservers have a good reputation because they have been building this up for a long time and send newsletters for lots of organizations.
     
  6. edge

    edge Active Member Moderator

    MaxT likes this.
  7. MaxT

    MaxT Member HowtoForge Supporter

  8. Th0m

    Th0m ISPConfig Developer ISPConfig Developer

  9. pvanthony

    pvanthony Member HowtoForge Supporter

  10. elmacus

    elmacus Active Member HowtoForge Supporter

  11. pvanthony

    pvanthony Member HowtoForge Supporter

    Please note that I am not an expert. My objective is to prevent mass emails out. For example when a client uses a simple password and a bot start using the smtp account to blast a lot of email. There is a feature when something like that happens, rspamd can send an email to the administrator. Unfortunately I do not know how to do that yet. Here is the config.

    cat ratelimit.conf
    rates {

    only_50_per_hour = {
    selector = 'user.lower';
    bucket = {
    burst = 50;
    rate = "1 / 1min";
    }
    }


    }
     
    elmacus likes this.
  12. elmacus

    elmacus Active Member HowtoForge Supporter

    I use Monit to monitor Postfix que:
    https://serverfault.com/questions/697670/how-to-monitor-the-postfix-mail-queue-using-monit
    Code:
    nano /usr/local/sbin/check_postfix_queue
    Add this:
    Code:
    #!/bin/bash
    MAXMSG=20
    MSG=$( postqueue -p | egrep '\-\- [0-9]+ Kbytes in [0-9]+ Request*\.' | awk '{ print $5 }'  )
    [ ${MSG:-0} -le $MAXMSG ] && exit 0 || exit 1
    Then
    Code:
    chmod +x /usr/local/sbin/check_postfix_queue
    nano /etc/monit/monitrc.d/postfix-que
    Add this:
    Code:
    check program mail-queue path "/usr/local/sbin/check_postfix_queue"
       if status != 0 then alert
    Code:
    Then systemctl reload monit.service
    

     
    Jesse Norell likes this.
  13. pvanthony

    pvanthony Member HowtoForge Supporter

    Thank you for sharing this. I have not tried monit. Will look into it.
    Does monit state with email account is sending out too much email? That would be really good so that we can contact the person and try to alert the person that there might be something wrong on their computer.
     
  14. elmacus

    elmacus Active Member HowtoForge Supporter

    No, you need to check the mailq and individual emails:
    Code:
    mailq
    postcat -vq  MAILID
     
  15. pvanthony

    pvanthony Member HowtoForge Supporter

  16. pvanthony

    pvanthony Member HowtoForge Supporter

    Here is a possible solution. This solution came from Andrew Lewis from the Rspamd Telegram Channel. He wrote the code.
    In rspamd there is a module called metadata_exporter.
    https://rspamd.com/doc/modules/metadata_exporter.html
    Here is the code for getting an email alert when an authenticated user's email is rejected.
    In the file /etc/rspamd/local.d/metadata_exporter.conf
    Code:
    rules {
        # This rule sends an e-Mail alert over SMTP containing message metadata
        # when it sees a rejected mail from an authenticated user
        RATE_LIMIT_OVER {
          backend = "send_mail";
          smtp = "127.0.0.1";
          helo = "helo of ones email server";
          mail_from = "[email protected]";
          mail_to = "[email protected]";
          selector = "is_reject_authed";
          formatter = "email_alert";
        }
    }
    
    Let us say one needs more control. Like me because I need it to send an email alert only when the authenticated user's email is rejected because of a ratelimit exceed.
    Code:
    custom_select {
        my_special_selector = <<EOD
    return function(task)
      -- local rspamd_logger = require 'rspamd_logger' <-- to activate loging
      -- User must be authenticated
      -- rspamd_logger.infox(task, 'blah_user: %1', task:get_user()) <-- to see logs for task:get_user()
      if not task:get_user() then return false end
      -- Action must be `reject`
      -- rspamd_logger.infox(task, 'blah: %1', task:get_metric_action()) <-- to see logs for task:get_metric_action()
      if task:get_metric_action() ~= 'reject' then return false end
      -- Maybe we require some symbol to be present?
      -- if not task:get_symbol('RATELIMIT') then return false end <-- I need to find the right symbol name. Not sure if it is "RATELIMIT".
      return true
    end
    EOD;
      }
    
    rules {
        # This rule sends an e-Mail alert over SMTP containing message metadata
        # when it sees a rejected mail from an authenticated user
        RATE_LIMIT_OVER {
          backend = "send_mail";
          smtp = "127.0.0.1";
          helo = "helo of ones email server";
          mail_from = "[email protected]";
          mail_to = "[email protected]";
          selector = "my_special_selector";
          formatter = "email_alert";
        }
    
    }
    
    
    The email alert will have the user's email address.
     

Share This Page