Send emails in batches

Hello! Happy to join the Jenkins community:) I have a question:

We need to send out email notifications in batches because our SMTP server has a hard limit of sending them to 50 recipients at once. Is there any way I can tell the Jenkins configuration to manage sending emails on batches of at most 50 emaill?

Thanks!

I don’t know the answer, I’m just hoping to collect more info.

Which email plugin are you using? and/or whats the syntax your using?
Are you sending to a dynamic list such as all committers? or a static list?

I agree with @halkeye , we need more info. Preferably a sample snippet of code you are trying to use, as there are many ways of doing something in Jenkins.

In Pipeline I would do something like this:

node() {
    List<String> emails = ['joe@example.com', 'linda@example.com'] // pretend this is hundreds of users long.

    // break the list into smaller list of 50
    emails.collate(50).each { List<String> emailGroup ->
        // Loop over each email address in the smaller lists
        emailGroup.each { String user ->
            // send the email
            emailext(body: 'testing', to: user)
        }
    }

}

Hi guys, we are using vanilla Jenkins email sending with https://plugins.jenkins.io/email-ext/ “Email Extension” in top of it, no code added from our side.

We are sending the emails to a mixed static/dynamic list on each job: a few fixed emails and then also developers and culprits. We are a large commiteers base on our project and we can get to 50+ people to be part of the same build, which then creates the problem with our SMTP server, because it can’t handle more than 50 emails per send (it’s on AWS).

I will explore some of the suggestions for the pipeline, but we are using the job not in pipeline so I can’t think it would work out as is. What would help really help us is to have some way of telling Jenkins config to separate emails sending on batches of 50, everytime emails are requested to be sent.