Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages


home | help
Sympa::Message(3Sympa)		 sympa 6.2.56		Sympa::Message(3Sympa)

       Sympa::Message -	Mail message embedding for internal use	in Sympa

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

       While processing	a message in Sympa, we need to link information	to the
       message,	modify headers and such.  This was quite a problem when	a
       message was signed, as modifying	anything in the	message	body would
       alter its MD5 footprint.	And probably make the message to be rejected
       by clients verifying its	identity (which	is somehow a good thing	as it
       is the reason why people	use MD5	after all). With such messages,	the
       process was complex. We then decided to embed any message treated in a
       "Message" object, thus making the process easier.

   Methods and functions
       new ( $serialized, context => $that, KEY	=> value, ... )
	   Constructor.	 Creates a new Sympa::Message object.


	       Serialized message.

	   context => object
	       Context.	 Sympa::List object, Robot or '*'.

	   key => value, ...


	   A new Sympa::Message	object,	or undef, if something went wrong.

       dup ( )
	   Copy	constructor.  Gets deep	copy of	instance.

       to_string ( [ original => 0|1 ] )
	   Serializer.	Returns	serialized data	of Message object.


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


	   Serialized representation of	Message	object.

       add_header ( $field, $value, [ $index ] )
	   Instance method.  Adds a header field named $field with body
	   $value.  If $index is given,	the field will be inserted at the
	   place it indicates: If it is	0, the field will be prepended.

       delete_header ( $field, [ $index	] )
	   Instance method.  Deletes all occurrences of	the header field named

       replace_header (	$field,	$value,	[ $index ] )
	   Instance method.  Replaces header fields named $field with $value.

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

	   Note	that returned value is real reference to internal data
	   structure.  Even if it was changed, string representation of
	   message may not be updated.	Alternatively, use "add_header"(),
	   "delete_header"() or	"replace_header"() to modify header.

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

       dkim_sign ( dkim_d => $d, [ dkim_i => $i	], dkim_selector => $selector,
       dkim_privatekey => $privatekey )
	   Instance method.  Adds DKIM signature to the	message.

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

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

       check_arc_chain ( )
	   Instance method.  Checks ARC	chain of the message and sets
	   {shelved}{arc_cv} item of the message object.

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

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

	   Note	that returned value is real reference to internal data
	   structure.  Even if it was changed, string representation of
	   message may not be updated.	Below is better	way to modify message.

	       my $entity = $message->as_entity->dup;
	       # ... Modify $entity...

       set_entity ( $entity )
	   Instance method.  Updates message with MIME entity (MIME::Entity
	   instance).  String representation will be automatically updated.

       as_string ( )
	   Instance method.  Gets a string representation of message.


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

	   Note	that method like "set_string()"	does not exist:	You would be
	   better to create new	instance rather	than replacing entire content.

       body_as_string (	)
	   Instance method.  Gets body of the message as string.

	   Note	that the result	won't be decoded.

       header_as_string	( )
	   Instance method.  Gets 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 header field $field, stripping
	   trailing newline.

	   In scalar context without $sep, returns 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 header value decoded to UTF-8 or undef.
	   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.


	       the stream to which dump	the object


	   1.  if everything's alright

       add_topic ( $output )
	   Note: No longer used.

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


	       the string containing the topic to add


	   1.  if everything's alright

       get_topic ( )
	   Note: No longer used.

	   Instance method.  Gets topic	of message.




	   the topic
	       if it exists

	   empty string

       clean_html ( )
	   Instance method.  Encodes HTML parts	of the message by UTF-8	and
	   strips scripts included in them.

       smime_decrypt ( )
	   Instance method.  Decrypts message using private key	of user.

	   Note	that this method modifies Message object.




	   True	value if message was decrypted.	 Otherwise false value.

	   If decrypting succeeded, {smime_crypted} item is set.

       smime_encrypt ( $email )
	   Instance method.  Encrypts message using certificate	of user.

	   Note	that this method modifies Message object.


	       E-mail address of user.


	   True	value if encryption succeeded, or "undef".

       smime_sign ( )
	   Instance method.  Adds S/MIME signature to the message.

	   Signing key is taken	from what stored in list directory.




	   True	value if message was successfully signed.  Otherwise false

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




	   1 if	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	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.




	   1 if	the message is considered signed.  0 otherwise.

       personalize ( $list, [ $rcpt ], [ $data ] )
	   Instance method.  Personalizes a message with custom	attributes of
	   a user.


	       List object.


	       Hashref.	 Additional data to be interpolated into personalized


	   Modified message itself, or "undef" if 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	list.



	   1 if	succeed, 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.


	       Message body with the TT2.

	       List object.

	       The recipient email.

	       Hashref.	 Additional data to be interpolated into personalized


	   Customized text, or "undef" if error	occurred.

       prepare_message_according_to_mode ( $mode, $list	)
	   Instance method.  Transforms	the message according to 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 modified message object itself, or "undef" if
	   transformation failed.

       decorate	( )
	   OBSOLETED.  Use prepare_message_according_to_mode('mail', $list).

	   Instance method.  Adds footer/header	to a message.

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

	   MIME-compliant headers are appended / modified.  And	custom
	   X-Mailer: header is appended	:).


	       ref(ARRAY) - messages to	be attached as subparts.



       get_plain_body (	)
	   Instance method.  Gets decoded content of text/plain	part.

	   The text will be converted to UTF-8.	 Flowed	text (see RFC 3676)
	   will	be conjuncted.

       check_virus_infection ( [ debug => 1 ] )
	   Instance method.  Checks the	message	using anti-virus plugin, if
	   configuration requests it.




	   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 message, suitable
	   for use in plain text digests.

	   o   Most attachments	are stripped out and replaced with a note that
	       they've been stripped. text/plain parts are retained.

	   o   An attempt to convert text/html parts to	plain text is made if
	       there is	no text/plain alternative.

	   o   All messages are	converted from their original character	set to

	   o   Parts of	type message/rfc822 are	recursed through in the	same
	       way, with brief headers included.

	   o   Any line	consisting only	of 30 hyphens has the first character
	       changed to space	(see RFC 1153).	Lines are wrapped at 76





       dmarc_protect ( )
	   Instance method.  Munges the	"From:"	header field if	we are using
	   DMARC Protection mode.




	   None.  "From:" field	of the message may be modified.

       compute_topic ( )
	   Instance method.  Compute 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




	   String of tag(s), can be separated by ',', can be empty.

       get_id (	)
	   Instance method.  Gets unique identifier of instance.

   Context and Metadata
       Context and metadata given to constructor are accessible	as hash
       elements	of object.  These are typically	used.

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

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

	   Domain, name, type and local	part of	context.

	   Priority of the message.

	   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.

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

       These are accessible as hash elements of	objects.

	   No longer used.  It is kept for compatibility with Sympa 6.1.x or
	   earlier.  See also upgrade_send_spool(1).

	   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".

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

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

	   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.

	   Original message ID of the message.

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

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

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

	   dkim_sign =>	1
	       Adding DKIM signature.

	   dmarc_protect => 1
	       DMARC protection.  See also "dmarc_protect"().

	   merge => 1

	   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.

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

       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

       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.

	 X-Sympa-Message-ID: : {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:		 : {envelope_sender} attribute
	 Message-Id: <>	 :   ---
	 From: Infant <>		 :    |
	 To: User <>			 :    |
	 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.

   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,

	   Add "P" in the "F=" flags of	local mailer line (such	as "Mlocal").

	       Prepending "Return-Path:" is available by default.

	       Add "R" to the "flags=" attributes in

	   Set "return_path_add" to be true with pipe_transport.

	   Use preline(1).

	   As of version 0.7, prepending "Return-Path:"	is available.

       get_plaindigest_body() seems to ignore any text after a UUencoded

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

       o   Serge Aumont	<sa AT>

       o   Olivier Salauen <os AT>

       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.

6.2.56				  2020-05-24		Sympa::Message(3Sympa)


Want to link to this manual page? Use this URL:

home | help