Skip to Content.
Sympa Menu

en - RE: [sympa-users] Testing mailmerge

Subject: The mailing list for listmasters using Sympa

List archive

Chronological Thread  
  • From: Steve Shipway <address@concealed>
  • To: "address@concealed" <address@concealed>
  • Subject: RE: [sympa-users] Testing mailmerge
  • Date: Thu, 29 May 2014 02:51:42 +0000

After searching through the code (v6.1.19), it turns out this is actually very easy to do.

 

One line change in Scenario.pm to allow test_it as a valid response along with do_it.

 

                ## Check syntax of returned action

                unless ($action =~ /^(do_it|reject|request_auth|owner|editor|editorkey|listmaster|ham|spam|unsure|test_it)/) {

 

In sympa.pl, subroutine DoMessage, add test_it as well as do_it as distribution actions,

 

    if (($action =~ /^(do_it|test_it)/) || ($main::daemon_usage == DAEMON_MESSAGE)) {

 

and pass test_mode=>1 to distribute_msg if $action="~/test_it/

 

            eval { $numsmtp =$list->distribute_msg('message'=> $message,

                                                   'apply_dkim_signature'=>$apply_dkim_signature,

                                                   'test_mode'=>(($action="~/test_it/)?1:0)

                )};

 

In List.pm, check for the test_mode parameter, and if true, add the header X-Sympa-Receipient (yes that spelling error is supposed to be there) which should contain the email address from the From header.  This needs to occur before the DMARC-munging and Anonymisation steps.

 

    if($param{‘test_mode’}) {

        my $originalFromHeader = $hdr->get('From');

        my @addresses = Mail::Address->parse($originalFromHeader);

        $hdr->add('X-Sympa-Test', 'YES') ;

        if(@addresses) {

                $hdr->add('X-Sympa-Receipient', $addresses[0]->address );

        } else {

                $hdr->add('X-Sympa-Receipient', $self->{'name'}."-owner\@".$self->{'domain'} );

        }

    }

 

And that is it.  I’ve done it in our test environment, and set up a send scenario that has ‘test_it’ if the Subject contains ‘TEST’, and it works – the merged message is sent only back to the sender, not to the normal list recipients.

 

There may be a couple of other places (in the topic check, and in wwsympa’s online Send function) that it might be worth adding test_it as an equal result to do_it but I didn’t see any others.

 

I was expecting more work to be involved, but it seems the Sympa team have already set up an undocumented test feature with the X-Sympa-Receipient header to do this.  However it is difficult to set custom headers when sending messages and so using a scenario that can be made to check for patterns in the subject line is more flexible.   Having test_it as a distinct outcome seems to me to be better than using do_it with a modifier (‘do_it,test’) but that may be personal preference.  I would think that using a modifier implies that the message will still be distributed to list members, so I used a separate outcome to emphasise the difference.

 

I can create a context diff for this if people are interested and do not have any other suggestions for its improvement. 

 

Steve

 

Steve Shipway

address@concealed

 

Attachment: smime.p7s
Description: S/MIME cryptographic signature




Archive powered by MHonArc 2.6.19+.

Top of Page