Dovecot Sieve how to set mail raw_text variable

i have filter

require ["envelope", "variables", "vnd.dovecot.pipe"];

if envelope :matches "To" "[email protected]" {
  set "recipient" "${0}";

  if header :matches "From" "*" {set "sender" "${0}";}
  if header :matches "Date" "*" { set "date" "${0}"; }
  if header :matches "Content-Type" "*" { set "content_type" "${0}"; }
  if header :matches "Subject" "*" { set "subject" "${0}"; }
  if header :matches "Message-ID" "*" { set "message_id" "${0}"; }


  pipe "forwarding_cimp.sh" ["message_id:${message_id} date:${date} content_type:${content_type} sender:${sender} recipient:${recipient} subject:${subject} body:${body} body2:${body2}"];
}

how to set variable with email raw text

if body :content "text" :matches "*" {set "body_text" "${0}"; # not working}

if body :raw :contains "*" {set "raw_text" "${0}"; # not working too} how ho get email message raw text

Upvotes: 0

Views: 781

Answers (1)

ernix
ernix

Reputation: 3643

I think you are looking for extracttext extension, see rfc5703:

require "extracttext";
require "foreverypart";
require "mime";
require "variables";

set "body" "";
foreverypart {
    if header :mime :type :is "Content-Type" "text" {
        extracttext "content";
        set "body" "${body}${content}";
    }
}

Upvotes: 0

Related Questions