Matching SES send rate

@geimsdin I wasn’t sure whether I should reply to such a bs and offending post.
I am no longer using Mautic at all. So you are lucky that I forgot to deactivate my profile here.
At the time I had the problem, nobody could give me an answer. So what did I steal @geimsdin?
Almost one year ago I tried a quick and dirty solution to get it run within a day or two.

The below solution did work for us with Mautic 4.1.1 AND I can’t say if it will still works with newer Mautic versions, as we stopped using Mautic since March 2022. The main reason was the dodgy behaviour of the template generator and the email generation (even when using MJML). It was not reliable and easy enough for us.

What I basically did:

  1. create a shell script, which creates n spool folders
/var/www/html/var/spoolemail01
/var/www/html/var/spoolemail01
/var/www/html/var/spoolemail01
/var/www/html/var/spoolemailNN
  1. create a shell script with n calls of the email sending command:
    File /var/www/html/bin/multiemails.sh
#!/bin/bash
threads=20
threadsa=$[$threads+1]

/var/www/html/bin/movebalanced.sh

i=1

while [ $i -lt $threadsa ]; do
  fileext="$(printf "%02d" $i)"
  php /var/www/html/bin/console mautic:emails:send --lock-name=email$fileext &
  i=$[$i+1]
done
  1. Create a shell script to move the spooled emails into the n spool folders.
    File /var/www/html/bin/movebalanced.sh
#!/bin/bash

threads=20
countfiles=`ls /var/www/html/var/spool/*.message | wc -l`

if [ $countfiles -gt 0 ]
then
        files_per_folder=$((($countfiles/$threads)))
        rest=$(($countfiles-($files_per_folder*$threads)))
        resta=$(($rest+1))
        k=1
        threadsa=$((($threads+1)))
        while [ $k -lt $threadsa ]; do
                i=0
                fileext="$(printf "%02d" $k)"
                if [ "$k" -lt $resta ];
                then
                        new_files_per_folder=$((($files_per_folder+1)))
                else
                        new_files_per_folder=$((($files_per_folder)))
                fi
                echo $new_files_per_folder

                for x in /var/www/html/var/spool/*.message; do
                  if [ "$i" = $new_files_per_folder ]; then break; fi
                  mv -n -- "$x"  /var/www/html/var/spoolemail$fileext/
                  i=$((i+1))
                done
                k=$[$k+1]
        done
fi
  1. change the console command so that it allows to use the parameter
    a. File /var/www/html/bin/console

Insert

define('V_SPOOL_FOLDER_EXT',$input->getParameterOption('--lock-name') ?? '');

after

$input = new ArgvInput();

b. File /var/www/html/app/bundles/EmailBundle/Command/ProcessEmailQueueCommand.php

Replace in line 102

$spoolPath = $this->parametersHelper->get('mautic.mailer_spool_path');

with

$spoolPath = $this->parametersHelper->get('mautic.mailer_spool_path').$lockName;

c. File /var/www/html/app/bundles/EmailBundle/Config/config.php

Enter

if (defined("V_SPOOL_FOLDER_EXT")) 
{
    $vSpoolFolderExt = "". V_SPOOL_FOLDER_EXT;
}
else
{
    $vSpoolFolderExt = "";
}

before

return [ 'routes' => [

d. File /var/www/html/app/bundles/EmailBundle/Swiftmailer/Spool/DelegatingSpool.php, function private function getSpoolDir(): string

Enter


if (defined("V_SPOOL_FOLDER_EXT")) 
{
   $vSpoolFolderExt = "". V_SPOOL_FOLDER_EXT;
}
else 

{
    $vSpoolFolderExt = "";
}

before

$filePath = $this->coreParametersHelper->get('mailer_spool_path');

and change

$filePath = $this->coreParametersHelper->get('mailer_spool_path');

to

$filePath = $this->coreParametersHelper->get('mailer_spool_path').$vSpoolFolderExt;

e. crontab
Enter

* * * * * /var/www/html/bin/multiemail.sh

Deactivate

#* * * * * php /var/www/html/bin/console mautic:emails:send

I can’t guarantee that this solution will work for anyone.

I am still surprised that this issue hasn’t been solved by the developers as it is very crucial.
The reason I went this path was, that multiple processes of the email sending command run on the one default spool folder caused multiple send outs of one email spool file. We basically didn’t want to spam our customers. We had to sent out 100,000 emails within a short period of time, so needed a parallel sent out functionality. But the one offered by Mautic caused lots of headaches and this solution helped us for the time we were using Mautic.

1 Like