X-Mailer: SwiftMailer - 5.4.x - can we delete mailer info in the header?

rafe3000

New Member
Is there a possibility. I have not found a setting for this.

Thanks for your help!
 

Attachments

  • header.jpg
    header.jpg
    81.6 KB · Views: 13
s there a possibility. I have not found a setting for this.
There is a hook you could use.
The hook name is 'mailer_after_create_message_instance', so you can create a file called init-custom.php in the /apps/ folder and put this in it:

PHP:
Yii::app()->hooks->addFilter('mailer_after_create_message_instance', function($message, $params, $mailer) {
    // make sure we get the right mailer and not phpmailer...
    if (!($mailer instanceof MailerSwiftMailer) || !($message instanceof Swift_Message)) {
        return $message;
    }
    // remove the header
    $message->getHeaders()->remove(sprintf('%sMailer', Yii::app()->params['email.custom.header.prefix']));

    // return the message in the end
    return $message;
});
 
Back
Top