Skip to content

mailer add recepient duplicates #5

@systemmind

Description

@systemmind

I investigated the next issue. The Mailer class contains static PHPMailer instance. When user clicks Mail::send() function than the Mailer::send() function is called. The Mailer::send() function calls $mailer->addReplyTo(), $mailer->addCC() and $mailer->addBCC() functions. Because PHPMailer is static it keeps all these recipients and nobody clears them. When server sends emails to users (for example on email validation stage) it becomes insert all these recipients to each concrete email that must be delivered only to single mail box. But now each email contains few recipients.

I fixed this by inserting this 3 lines to the Mailer::send() function:

        if (static::validate($mail)) {
            $mail = $mail->getMail();

            static::$mailer->clearAddresses();
            static::$mailer->clearCCs();
            static::$mailer->clearBCCs();

But maybe there is better solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions