Sympa::Message(3Sympa)

๐Ÿ’Œ NAME ๐Ÿ’Œ

Sympa::Message โ€” mail message embedding for internal use in Sympa ๐Ÿซถ

(you're reading the Sympa::Message(3Sympa) page, straight out of the sympa 6.2.80 manual, bestie โœจ)


๐ŸŒธ SYNOPSIS ๐ŸŒธ

use Sympa::Message;
my $message = Sympa::Message->new($serialized, context => $list);

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

Okay so picture this: while Sympa is processing a message, it has to link extra info to that message, rewrite headers, all of that. And back in the day that was lowkey a whole situation ๐Ÿ˜ญ because if the message was signed, touching anything in the body would change its MD5 footprint. And then the message would probably get rejected by the clients that verify its identity โ€” which is, honestly, kind of a good thing, since that's literally the entire reason people use MD5 in the first place. So with messages like that, the process was complex. The fix? Sympa decided to embed any message it handles in a "Message" object, and boom โ€” process made easier. slay ๐Ÿ’…

๐Ÿ”ฎ Methods and functions ๐Ÿ”ฎ

โญ new ( $serialized, context => $that, KEY => value, ... )

Constructor. Creates a brand new Sympa::Message object. โœจ

Parameters:

  • $serialized โ€” Serialized message.
  • context => object โ€” Context. A Sympa::List object, a Robot or '*'.
  • key => value, ... โ€” Metadata.

Returns:

  • A new Sympa::Message object, or undef, if something went wrong. ๐Ÿ˜ญ

๐Ÿ’– dup ( )

Copy constructor. Gets a deep copy of the instance. two of them. twins. iconic.


๐ŸŽ€ to_string ( [ original => 0|1 ] )

Serializer. Returns serialized data of the Message object.

Parameter:

  • original => 0|1 โ€” If set to 1 and content has been decrypted, returns original content. Default is 0.

Returns:

  • Serialized representation of the Message object.

๐ŸŒˆ add_header ( $field, $value, [ $index ] )

Instance method. Adds a header field named $field with body $value. If $index is given, the field gets inserted at the place it indicates: if it is 0, the field will be prepended. front of the line energy.


๐Ÿ’… delete_header ( $field, [ $index ] )

Instance method. Deletes all occurrences of the header field named $field. gone. bye.


๐Ÿฆ‹ replace_header ( $field, $value, [ $index ] )

Instance method. Replaces header fields named $field with $value.


Instance method. Gets the header of the message as a MIME::Head instance.

Heads up bestie โš ๏ธ the returned value is a real reference to internal data structure. Even if you changed it, the string representation of the message may not be updated. Instead, use "add_header"(), "delete_header"() or "replace_header"() to modify the header. iykyk.

๐Ÿ”ฅ check_spam_status ( )

Instance method. Gets the spam status according to the spam_status scenario and sets it as the {spam_status} attribute.


๐ŸŒŸ aggregate_authentication_results ( )

Instance method. TBD. (yes, that's literally what it says ๐Ÿ’€)


๐Ÿงš dkim_sign ( dkim_d => $d, [ dkim_i => $i ], dkim_selector => $selector, dkim_privatekey => $privatekey )

Instance method. Adds a DKIM signature to the message. ๐Ÿ”


๐Ÿ’œ check_dkim_signature ( )

Deprecated on Sympa 6.2.71b. Use check_dkim_sigs().


๐Ÿ“ check_dkim_sigs ( )

Instance method. Checks the DKIM signature of the message and sets or clears the {dkim_pass} item of the message object.

Returns:

  • An array of the overall result of checking and authentication result(s).

๐ŸŒˆ remove_invalid_dkim_signature ( )

Deprecated on Sympa 6.2.74.

Instance method. Verifies DKIM signatures included in the message, and if any of them are invalid, removes them.


๐Ÿ’ซ check_arc_chain ( )

Deprecated on Sympa 6.2.71b. Use check_arc_seals().


๐ŸŽ€ check_arc_seals ( )

Instance method. Checks the chain of ARC seals in the message.

Returns:

  • An array of the result of checking and authentication result.

Note:

  • Use of aggregate_authentication_results() is recommended instead of using this method derectly. (their spelling, not mine ๐Ÿ™ˆ)

๐Ÿฆ‹ arc_seal ( )

Instance method. Adds a new ARC seal if there's an {arc_cv} from check_arc_seals() and the cv is none or valid.

Returns true value if the seal was successfully added. ๐ŸŽ‰


โœจ as_entity ( )

Instance method. Gets message content as a MIME entity (MIME::Entity instance).

Note that the returned value is a real reference to internal data structure. Even if it was changed, the string representation of the message may not be updated. Below is the better way to modify a message. ๐Ÿ‘‡
my $entity = $message->as_entity->dup;
# ... Modify $entity...
$message->set_entity($entity);

๐Ÿ’– set_entity ( $entity )

Instance method. Updates the message with a MIME entity (MIME::Entity instance). String representation will be automatically updated. no extra steps, we love that.


๐ŸŒธ as_string ( )

Instance method. Gets a string representation of the message.

Parameter:

  • original => 0|1 โ€” If set to 1 and content has been decrypted, returns original content. Default is 0.
Note that a method like "set_string()" does not exist: you would be better off creating a new instance rather than replacing the entire content. fr fr.

โญ body_as_string ( )

Instance method. Gets the body of the message as string.

Note that the result won't be decoded.


๐ŸŽ€ header_as_string ( )

Instance method. Gets the header part of the message as string.

Note that the result won't be decoded nor unfolded.


๐Ÿงš get_header ( $field, [ $sep ] )

Instance method. Gets value(s) of the header field $field, stripping the trailing newline.

In scalar context without $sep, returns the first occurrence or "undef". If $sep is defined, returns all occurrences joined by it, or "undef". Otherwise, in array context, returns an array of all occurrences or "()".

Note: Folding newlines will not be removed. ๐Ÿ™ˆ

๐Ÿ’… get_decoded_header ( $tag, [ $sep ] )

Instance method. Returns the header value decoded to UTF-8, or undef. The trailing newline will be removed. If $sep is given, returns all occurrences joined by it.


๐Ÿ“ dump ( $output )

Instance method. Dumps a Message object to a stream.

Parameters:

  • $output โ€” the stream to which dump the object.

Returns:

  1. if everything's alright ๐ŸŽ‰

๐Ÿ’ซ add_topic ( $output )

Note: No longer used.

Instance method. Adds a topic and puts the header X-Sympa-Topic.

Parameters:

  • $output โ€” the string containing the topic to add.

Returns:

  1. if everything's alright ๐ŸŽ‰

๐ŸŒˆ get_topic ( )

Note: No longer used.

Instance method. Gets the topic of the message.

Parameters:

  • None.

Returns:

  • the topic โ€” if it exists
  • empty string โ€” otherwise

๐Ÿงš clean_html ( )

Instance method. Encodes HTML parts of the message by UTF-8 and strips scripts included in them. ๐Ÿงผโœจ


๐Ÿ‘‘ smime_decrypt ( )

Instance method. Decrypts the message using the private key of the user.

Note that this method modifies the Message object.

Parameters:

  • None.

Returns:

  • True value if the message was decrypted. Otherwise false value.
  • If decrypting succeeded, the {smime_crypted} item is set.

๐Ÿ”ฅ smime_encrypt ( $email )

Instance method. Encrypts the message using the certificate of the user.

Note that this method modifies the Message object.

Parameters:

  • $email โ€” E-mail address of the user.

Returns:

  • True value if encryption succeeded, or "undef".

โญ smime_sign ( )

Instance method. Adds an S/MIME signature to the message.

Signing key is taken from what's stored in the list directory. ๐Ÿ—๏ธ

Parameters:

  • None.

Returns:

  • True value if the message was successfully signed. Otherwise false value.

๐Ÿฆ‹ check_smime_signature ( )

Instance method. Verifies the S/MIME signature of the message, and if verification succeeded, sets the {smime_signed} item to true.

Parameters:

  • None

Returns:

  • 1 if the signature is successfully verified. 0 otherwise. "undef" if something went wrong. ๐Ÿ˜ญ

๐Ÿ’œ is_signed ( )

Instance method. Checks if the message is signed.

Note: This checks if the message has the appropriate content type and header parameters. Use check_smime_signature() to check if the message has properly signed content. โš ๏ธ

Currently, S/MIME-signed messages with content type "multipart/signed" or "application/pkcs7-mime" (with smime-type="signed-data" parameter) are recognized. Enveloped-only messages are not supported. The other signature mechanisms such as PGP/MIME have not been supported yet.

Parameters:

  • None.

Returns:

  • 1 if the message is considered signed. 0 otherwise.

๐ŸŽ€ personalize ( $list, [ $rcpt ] )

Instance method. Personalizes a message with custom attributes of a user. โœจ

Parameters:

  • $list โ€” List object.
  • $rcpt โ€” Recipient.
  • $data โ€” Hashref. Additional data to be interpolated into the personalized message.

Returns:

  • The modified message itself, or "undef" if an error occurred. ๐Ÿ˜ญ

๐ŸŒŸ test_personalize ( $list )

DEPRECATED by Sympa 6.2.13. No longer available.

Instance method. Tests if personalization can be performed successfully over all subscribers of the list.

Parameters:

Returns:

  • 1 if it succeeded, or "undef".

๐Ÿ’– personalize_text ( $body, $list, [ $rcpt ], [ $data ] )

Function. Retrieves the customized data of the users, then parses the text. It returns the personalized text.

Parameters:

  • $body โ€” Message body with the TT2.
  • $list โ€” List object.
  • $rcpt โ€” The recipient email.
  • $data โ€” Hashref. Additional data to be interpolated into the personalized message.

Returns:

  • Customized text, or "undef" if an error occurred. ๐Ÿ’€

๐Ÿฆ‹ prepare_message_according_to_mode ( $mode, $list )

Instance method. Transforms the message according to the reception mode: 'mail', 'notice' or 'txt'.

Note: 'html' mode was deprecated as of 6.2.23b.2.

By 'nomail', 'digest', 'digestplain' or 'summary' mode, the message is not modified.

Returns the modified message object itself, or "undef" if the transformation failed.


๐ŸŽ€ decorate ($list, [ mode => personalization mode ] )

Instance method. Adds a footer/header to a message. ๐Ÿ’…


๐Ÿ”ฅ reformat_utf8_message ( )

Instance method. Reformats bodies of text parts contained in the message using the recommended encoding schema and/or charsets defined by MIME::Charset.

MIME-compliant headers are appended / modified. And a custom X-Mailer: header is appended :). ๐Ÿฅฐ

Parameters:

  • $attachments โ€” ref(ARRAY) - messages to be attached as subparts.

Returns:

  • string

๐ŸŽ€ shelve_personalization ( type => $type )

Instance method, bestie. It shelves personalization (aka the "merge feature") if it needs to. $type is either 'web' or 'mail'.

๐Ÿšจ Heads up: this one dies if the context of the message was not List. Not a vibe. Just gone. ๐Ÿ’€

๐ŸŒธ get_plain_body ( )

Instance method. Gets you the decoded content of the text/plain part.

The text gets converted to UTF-8, and flowed text (see RFC 3676) gets conjuncted. Periodt. โœจ


๐Ÿ’… check_virus_infection ( [ debug => 1 ] )

Instance method. Checks the message using the anti-virus plugin โ€” but only if the configuration requests it. No config, no check, no drama.

Parameters:

  • TBD. (yes, it literally says TBD, we don't make the rules ๐Ÿซ )

Returns:

  • The name of malware the message contains, if any;
  • "unknown" for unidentified malware;
  • "undef" if checking failed;
  • otherwise 0.

๐Ÿฆ‹ get_plaindigest_body ( )

Instance method. Returns a plain text version of the message, suitable for use in plain text digests. Here's the tea, point by point:

  • Most attachments are stripped out and replaced with a note that they've been stripped. text/plain parts are retained.
  • An attempt to convert text/html parts to plain text is made if there is no text/plain alternative.
  • All messages are converted from their original character set to UTF-8.
  • Parts of type message/rfc822 are recursed through in the same way, with brief headers included.
  • Any line consisting only of 30 hyphens has the first character changed to space (see RFC 1153). Lines are wrapped at 76 columns.

Parameters:

None.

Returns:

String.


๐Ÿ‘‘ dmarc_protect ( )

Instance method. Munges the "From:" header field if we are using DMARC Protection mode. Munges!! okay!!

Parameters:

None.

Returns:

None. But lowkey important: the "From:" field of the message may be modified. ๐Ÿ™ˆ


๐Ÿ“ compute_topic ( )

Instance method. Computes the topic of the message. The topic is got from keywords defined in list parameter msg_topic.keywords. The keyword is applied on the subject and/or the body of the message according to list parameter msg_topic_keywords_apply_on.

Parameters:

None.

Returns:

String of tag(s), can be separated by ',', can be empty. So like, might be nothing. It's giving "we'll see". โœจ


๐Ÿงš get_id ( )

Instance method. Gets the unique identifier of the instance.

Short, sweet, iconic. No notes. ๐Ÿ’–


๐ŸŒˆ Context and Metadata ๐ŸŒˆ

The context and metadata you hand to the constructor are accessible as hash elements of the object. These are the ones everybody actually uses:

{context}

Context of the message, Sympa::List object, robot or '*'.

{date}

The UNIX time messages was initially accepted, or the time message should be delivered.

{domainpart} {listname} {listtype} {localpart}

Domain, name, type and local part of context.

{priority}

Priority of the message. Prioritizing!! ๐Ÿ’…

{tag}

Tag of packet used by bulk spool to control logging. '0' is the first message of multiple packet. 'z' is the last. 's' is the single message with single packet.

{time}

The Unix time in floating point number when the message was stored into the spool. This is used by bulk spool.


๐Ÿ’– Attributes ๐Ÿ’–

These are accessible as hash elements of objects.

{checksum}

No longer used. It is kept for compatibility with Sympa 6.1.x or earlier. See also sympa upgrade incoming command line. (Retro vibes only, don't touch. โœ‹)

{envelope_sender}

Envelope sender, a.k.a. "Unix From". This is not always same as {sender} attribute nor the content of "From:" field.

'<>' will be used for "null envelope sender".

{family}

Name of family (see Sympa::Family) the message corresponds to. This is given by familyqueue(8) program.

{gecos}

Display name of actual sender (see {sender} below), if any.

{md5_check}

True value indicates that the message has been authenticated by "md5" level (password authentication). This is set by web mailer of WWSympa and used by incoming spool.

{message_id}

Original message ID of the message.

{rcpt}

Recipients for delivery. This is kept for compatibility with earlier releases.

{sender}

Actual sender of the message. This is determined according to "sender_headers" configuration parameter. See also {envelope_sender} above.

{shelved}

Shelved processing. Hashref with multiple items. Currently these items are available:

  • arc_cv => "pass"|"fail"|"none" โ€” Result of checking the chain of ARC seals. This is used to generate a new ARC seal, if ARC feature is enabled.
  • decorate => 1 โ€” Adding footer/header if any.

This item was added on Sympa 6.2.59b.2 to avoid processing decoration twice with the messages stored into outgoing spool by earlier version of Sympa.

  • dkim_sign => 1 โ€” Adding DKIM signature.
  • dmarc_protect => 1 โ€” DMARC protection. See also "dmarc_protect"().
  • merge => "footer"|"all" โ€” Personalizing.

On Sympa 6.2.58 or earlier, there was no distinction between "footer" and "all". The "merge" item in the messages stored into outgoing spool by earlier version of Sympa will be treated as "all".

  • smime_encrypt => 1 โ€” Adding S/MIME encryption.
  • smime_sign => 1 โ€” Adding S/MIME signature.
  • tracking => "dsn"|"mdn"|"r"|"w"|"verp" โ€” Requesting tracking feature including VERP.

This is used by bulk spool.

{spam_status}

Result of spam check. This is set by "check_spam_status"() method.


๐Ÿซง Serialization ๐Ÿซง

A Sympa::Message object includes number of slots as hash items: metadata, context, attributes and message content. Metadata including context are given by spool: See "Marshaling and unmarshaling metadata" in Sympa::Spool.

Logically, objects are stored into physical spool as serialized form and deserialized when they are fetched from spool. Attributes will be serialized and deserialized along with raw message content. Attributes are encoded in "X-Sympa-*:" pseudo-header fields and "Return-Path:" header field. Below is an example of serialized form. Look at her. Gorgeous. โœจ

X-Sympa-Message-ID: 123456789.12345@domain.name : {message_id} attribute
X-Sympa-Sender: user01@user.sympa.test          : {sender} attribute
X-Sympa-Display-Name: Infant                    : {gecos} attribute
X-Sympa-Shelved: dkim_sign; tracking=mdn        : {shelved} attribute
X-Sympa-Spam-Status: ham                        : {spam_status} attribute
Return-Path: sympa-request@domain.name          : {envelope_sender} attribute
Message-Id: <123456789.12345@domain.name>       :   ---
From: Infant <user@other.host.dom>              :    |
To: User <user@some.host.name>                  :    |
Subject: Howdy world                            :    | Raw message content
X-Sympa-Topic: sometopic                        :    |
                                                :    |
Bonjour, le monde.                              :    |
                                                :   ---

On msg, automatic and bounce spools, "Return-Path:" header fields are given by MDA and "X-Sympa-*:" header fields are given by queue programs. On other spools, they are given by components of Sympa.

Pseudo-header fields should appear at beginning of serialized content. Fields appear at other places (e.g. "X-Sympa-Topic:" field above) are not attributes but are the part of raw message content.

Pseudo-header fields should not be included in actually sent messages. Do not. ๐Ÿšซ


โš ๏ธ CAVEAT โš ๏ธ

Adding "Return-Path:" field

We trust in "Return-Path:" header field only at the top of message to prevent forgery. To ensure it will be added to messages by MDA:

  • Sendmail โ€” Add "P" in the "F=" flags of local mailer line (such as "Mlocal").
  • Postfix
    • local(8) โ€” Prepending "Return-Path:" is available by default.
    • pipe(8) โ€” Add "R" to the "flags=" attributes in master.cf.

Additionally with Postfix 2.3 or later, add an empty "null_sender=" attribute. Or "null envelope sender" would be replaced with "<MAILER-DAEMON>".

  • Exim โ€” Set "return_path_add" to be true with pipe_transport.
  • qmail โ€” Use preline(1).
  • sympa-milter โ€” As of version 0.7, prepending "Return-Path:" is available.

Configure your MDA correctly, bestie. This is not the part to freestyle. ๐Ÿ™


๐Ÿ› BUGS ๐Ÿ›

get_plaindigest_body() seems to ignore any text after a UUencoded attachment.

Yeah. She just stops reading. It's giving "known issue" energy. ๐Ÿ˜ญ


๐Ÿ“œ HISTORY ๐Ÿ“œ

Message module appeared on Sympa 3.3.6. It was initially written by:

  • Serge Aumont <sa AT cru.fr>
  • Olivier Salaรผn <os AT cru.fr>

get_plaindigest_body, ex. "plain_body_as_string" in PlainDigest, was initially written by Chris Hastie. It appeared on Sympa 4.2b.1.

(c) Chris Hastie 2004 - 2008.

Renamed and merged Sympa::Message appeared on Sympa 6.2.


Okay we did it, that's the whole page, no crumbs left ๐Ÿ’…โœจ โ€” this was version 6.2.80, dated 2026-10-19, and yeah, it's the Sympa::Message(3Sympa) man page. Go forth and never forge a Return-Path: header, mwah ๐Ÿซถ๐Ÿ’–

๐Ÿ“ฆ where this page comes from