In my Joomla! 4.2+ component, i have something with send mail when an user submit a from, the issue is that the sending mail process is very slow. My component fetch the mail settings from the Joomla! configuration panel. This is the code, i don't see what this code hang the process of controller when submit the form :

abstract class MycomponentEmail
public static function send($mail, array $receivers)
    if (isset(static::$mailer_error_status)) {
        // Mailer is broken, so prevent any sending
        Log::add(static::$mailer_error_status->getMessage(), Log::ERROR, 'mycomponent');

        return false;
    $chunks = array_chunk($receivers, $emailRecipientCount);

    $success = true;

    foreach ($chunks as $emails) {
       if ($emailRecipientCount == 1 || $emailRecipientPrivacy == 'to') {
       } elseif ($emailRecipientPrivacy == 'cc') {
       } else {

       try {
       } catch (Exception $e) {
          $success = false;
          Log::add($e->getMessage(), Log::ERROR, 'mycomponent');

   return $success;


The controller call that :

public function sendNotification($url = null, $approved = false)
    // Create email.
        $mail = Factory::getMailer();
        $mail->setSender([$config->getEmail(), $mailnamesender]);

        // Send email to all subscribers.
        if (!empty($receivers[1])) {
            $this->attachEmailBody($mail, 1, $subject, $url, $once);
            MycomponentEmail::send($mail, $receivers[1]);


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.