Switching off X-mailer header

Discussion in 'Tips and tricks' started by Georgie, Jul 31, 2017.

Tags:
  1. Georgie

    Georgie New Member

    Joined:
    Dec 1, 2015
    Messages:
    25
    Likes Received:
    0
    S.E:
    Expired
    L.T:
    Regular
    L.C:
    1
  2. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    9,942
    Likes Received:
    2,328
  3. Georgie

    Georgie New Member

    Joined:
    Dec 1, 2015
    Messages:
    25
    Likes Received:
    0
    S.E:
    Expired
    L.T:
    Regular
    L.C:
    1
    @twisted1919 Which file should I change? Which line should I delete?
     
  4. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    9,942
    Likes Received:
    2,328
    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 likes this.
  5. Georgie

    Georgie New Member

    Joined:
    Dec 1, 2015
    Messages:
    25
    Likes Received:
    0
    S.E:
    Expired
    L.T:
    Regular
    L.C:
    1
    @twisted1919, How i can Spintax X-mailer Header?
    X-Mailer: [RandomContent:Apple Mail (2.1077)|Apple Mail (2.1081)|Apple Mail (2.1082)]?
     
  6. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    9,942
    Likes Received:
    2,328
    @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;
    });
     
    Colt405 likes this.
  7. Georgie

    Georgie New Member

    Joined:
    Dec 1, 2015
    Messages:
    25
    Likes Received:
    0
    S.E:
    Expired
    L.T:
    Regular
    L.C:
    1
  8. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    9,942
    Likes Received:
    2,328
    @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 likes this.
  9. Joseph Ollero

    Joseph Ollero Member

    Joined:
    Feb 8, 2017
    Messages:
    50
    Likes Received:
    3
    S.E:
    2019-11-24 08:04:44
    L.T:
    Regular
    L.C:
    4
    This is an interesting topic. What is the main benefit of having a dynamic X-mailer header? For better opens?
     
  10. newuser

    newuser New Member

    Joined:
    Mar 16, 2018
    Messages:
    1
    Likes Received:
    0
    S.E:
    Expired
    L.T:
    Regular
    L.C:
    1
    Hello,
    Should it work with Mailwizz 1.6.3 ?
    I try it, but i still get the Mailswift header.
    Thank you
     
  11. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    9,942
    Likes Received:
    2,328
    Edit the MailerSwiftMailer.pgp file in this case.
     

Share This Page