Skip to Content.
Sympa Menu

en - Re: [sympa-users] Custom condition / auto-reply question

Subject: The mailing list for listmasters using Sympa

List archive

Chronological Thread  
  • From: "Stefan Hornburg (Racke)" <address@concealed>
  • To: address@concealed
  • Subject: Re: [sympa-users] Custom condition / auto-reply question
  • Date: Thu, 9 Apr 2020 15:33:19 +0200

On 4/1/20 2:39 PM, Greg Foster wrote:
> Hello everyone,
>
> I have a need to provide the ability to generate an auto-reply to messages
> sent to a particular list based on time of day/day of week, of which I have
> working. In addition, I need to be able to forward a copy of the message
> that meets the criteria passed to the custom condition to an email address
> that is also a parameter passed to the customer condition.

Hello Greg,

I think a message hook is more appropriate for your task. Soji just added an
autoresponder plugin to our contribs repo
(https://github.com/sympa-community/sympa-contribs/tree/master/message_plugin_autoresponder).
Beware, that is new and
not thoroughly tested.

For your forward you better use a template like in my distribution
notification plugin
(https://github.com/racke/sympa-plugin-distribution-notification):

--snip--
[%# distribution_notification.tt2 ~%]
Content-Type: multipart/report; report-type=delivery-status;
boundary="[% boundary %]"
Subject: [%"Your message has been distributed to list
%1"|loc(list.name)|qencode%]
X-Loop: [% conf.email %]@[% domain %]

This is a MIME-encapsulated message.

--[% boundary %]
Content-Disposition: inline
Content-Description: Notification

[%|loc%]This is an automatic response sent by Sympa Mailing Lists
Manager.[%END%]
[% IF action == "delivered" -%]
[%|loc%]Message was successfully delivered to following address:[%END%]

[% recipient %]

[% ELSE -%]
Failed to deliver
[% END -%]

--[% boundary %]
Content-Type: message/rfc822
Content-Disposition: inline
X-Sympa-Attach: yes

[%# msg inserted here #%]

--[% boundary %]--
--snap--

Hope this helps

Regards
Racke

>
> I've been able to capture the message body of email messages that are plain
> text, non-multipart messages. However, when I send a multipart message
> (simple text message with an attachment), I'm not able to capture the body
> of the message for forwarding.
>
> I have the scenario setup such that is calls my custom condition twice.
> Once with a parameter that passes [msg_body] and another time that passes
> [msg_part->body]. It is my understanding that you need to check both of
> these due to one containing the non-multipart message body and the other
> containing the multipart message body. These are the last parameters
> passed to my custom condition where I shift all the other parameters off
> and capture the remaining (message body) data in a variable and process it
> based on whether it's an array or not:
>
> foreach my $part (@parts) {
>
> $body .= ref $part eq "ARRAY" ? join " ", @{$part} : $part;
>
> }
>
> In the end, $body will be empty if the message body is multipart.
>
> For debugging purposes, I even have my perl code dumping that contents of
> those parameters to a file and any time I send a multipart message, the
> dump file is empty.
>
> So, some questions:
>
> - Is my understanding of the [msg_body] and [msg_part->body] correct as far
> as one containing the non-multipart message body and the other contain the
> multipart message body?
>
> - Is my code to process the body content passed to my custom condition
> correct, or am I missing something?
>
> - Is there an easier way to forward a copy of a list message to another
> user using Sympa functions? Perhaps I'm over thinking this by trying to
> rebuild the message to forward it to another user?
>
> Any help is greatly appreciated.
>
> Thanks!
>
> ---
> Greg Foster
> IT Services, Enterprise Systems Group
> G20A Stright Hall
> Indiana University of Pennsylvania
> Indiana, PA 15701
> 724-357-2986
>
> "There are 10 kinds of people: those who understand binary and those who
> don't"
>


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

Attachment: signature.asc
Description: OpenPGP digital signature




Archive powered by MHonArc 2.6.19+.

Top of Page