Page 1 of 1

Adding Headers to Mail

Posted: Thu Nov 26, 2020 6:36 pm
by paul_w
Hello

I am trying to send my newsletter out through Postmarkapp smtp service and they require inserting a custom header into the outgoing emails. Is there any way to do this within dadamail please?

Currently using the latest stable version.

Thanks - Paul

Re: Adding Headers to Mail

Posted: Fri Nov 27, 2020 6:45 pm
by dadamail
There is a way - it's a little awkward. All these changes are most likely easiest to do in the Config.pm file.

Find the %EMAIL_HEADERS variable and add both the name and value of the header to this variable:

Code: Select all


%EMAIL_HEADERS = (


   'X-PM-MESSAGE-STREAM' => 'value of the this header',


    Date                        => undef,
    From                        => undef,
    To                          => undef,
    Cc                          => undef,
    Bcc                         => undef,
    Sender                      => undef,
    'Return-Path'               => undef,
    'Reply-To'                  => undef,
    'In-Reply-To'               => undef,
    References                  => undef,
    'X-Priority'                => undef,
    'X-Original-From'           => undef,
    'Content-Base'              => undef,
    List                        => undef,
    'List-Archive'              => undef,
    'List-Digest'               => undef,
    'List-Help'                 => undef,
    'List-ID'                   => undef,
    'List-Owner'                => undef,
    'List-Post'                 => undef,
    'List-Subscribe'            => undef,
    'List-Unsubscribe'          => undef,
    'List-Unsubscribe'          => undef,
	'List-Unsubscribe-Post'     => undef, 
    'List-URL'                  => undef,
    'X-BeenThere'               => undef,
	'X-Beenthere'               => undef,
    'Message-ID'                => undef,
    'Precedence'                => 'list',
    'X-Mailer'                  => "$PROGRAM_NAME $VER ",
    'X-Cc'                      => undef,
    'Content-type'              => undef,
    'Content-Transfer-Encoding' => undef,
    'Content-Disposition'       => undef,
    'MIME-Version'              => undef,
    Subject                     => '(no subject)',
	'X-Preheader'               => undef,
    Body                        => 'blank',
) unless keys %EMAIL_HEADERS;

Then, you'll need to add the header name to @EMAIL_HEADERS_ORDER:

Code: Select all

@EMAIL_HEADERS_ORDER = qw(
  Date
  From
  To
  Cc
  Bcc
  Sender
  Return-Path
  Reply-To
  In-Reply-To
  References
  X-Priority
  X-Original-From
  
  Precedence



  X-PM-MESSAGE-STREAM


  List
  X-List
  List-Archive
  List-Digest
  List-Help
  List-ID
  List-Owner
  List-Post
  List-Subscribe
  List-Unsubscribe
  List-Unsubscribe-Post
  List-URL
  X-BeenThere
  X-Beenthere
  
  X-Message-ID
  Message-ID

  X-Mailer
  X-Cc

  Content-type
  Content-Transfer-Encoding
  Content-Disposition
  Content-Base

  MIME-Version
  X-Preheader
  Subject
  ) unless scalar @EMAIL_HEADERS_ORDER;


And that should do it,