Switching off X-mailer header

Which file should I change? Which line should I delete?

Create the file apps/init-custom.php and in it put this:
Code:
Yii::app()->hooks->addFilter('console_command_send_campaigns_before_send_to_subscriber', function($emailParams, $campaign, $subscriber, $customer, $server){
    foreach ($emailParams['headers'] as $index => $header) {
        if ($header['name'] == 'WhateverHeaderNameHere') {
            unset($emailParams['headers'][$index]);
        }
    }
    return $emailParams;
});
 
@Georgie - Something like this:
PHP:
Yii::app()->hooks->addFilter('console_command_send_campaigns_before_send_to_subscriber', function($emailParams, $campaign, $subscriber, $customer, $server){
   foreach ($emailParams['headers'] as $index => $header) {
       if ($header['name'] == 'X-Mailer') {
           unset($emailParams['headers'][$index]);
       }
   }

   $values = array('Apple Mail (2.1077)', 'Apple Mail (2.1081)', 'Apple Mail (2.1082)');
   shuffle($values);

   $emailParams['headers'][] = array(
      'name' => 'X-Mailer',
      'value'  => $values[0],
   );
   return $emailParams;
});
 
@Georgie - Yeah, seems that particular header is added in a way that does not allow altering it, so the only way is to modify the file httpdocs/apps/common/components/mailer/MailerPHPMailer.php and look for
PHP:
$mailer->addCustomHeader(sprintf('%sMailer', Yii::app()->params['email.custom.header.prefix']), 'PHPMailer - ' . $mailer->Version);
and change it with
PHP:
$values = array('Apple Mail (2.1077)', 'Apple Mail (2.1081)', 'Apple Mail (2.1082)');
shuffle($values);
$mailer->addCustomHeader(sprintf('%sMailer', Yii::app()->params['email.custom.header.prefix']), $values[0]);
 
@Georgie - Yeah, seems that particular header is added in a way that does not allow altering it, so the only way is to modify the file httpdocs/apps/common/components/mailer/MailerPHPMailer.php and look for
PHP:
$mailer->addCustomHeader(sprintf('%sMailer', Yii::app()->params['email.custom.header.prefix']), 'PHPMailer - ' . $mailer->Version);
and change it with
PHP:
$values = array('Apple Mail (2.1077)', 'Apple Mail (2.1081)', 'Apple Mail (2.1082)');
shuffle($values);
$mailer->addCustomHeader(sprintf('%sMailer', Yii::app()->params['email.custom.header.prefix']), $values[0]);

Hello,
Should it work with Mailwizz 1.6.3 ?
I try it, but i still get the Mailswift header.
Thank you
 
Back
Top