Conversion Control

The actual conversions performed by the conversion channel are controlled by rules specified in the IMTA conversion file. This is the file specified by the IMTA_CONVERSION_FILE option in the IMTA tailor file. By default, this is the file /etc/opt/SUNWmail/imta/conversions.

The IMTA conversion file is a text file containing entries in a format that is modeled after MIME Content-Type: parameters. Each entry consists of one or more lines grouped together; each line contains one or more name=value; parameter clauses. Quoting rules conform to MIME conventions for Content-Type: header line parameters. Every line except the last must end with a semicolon (;). A physical line in this file is limited to 252 characters. You can split a logical line into multiple physical lines using the backslash (\) continuation character. Entries are terminated either by a line that does not end in a semicolon, one or more blank lines, or both. For example, the following entry specifies that application/wordperfect5.1 parts in messages sent to the local channel should be converted to DDIF:

 
out-chan=l; in-type=application; in-subtype=wordperfect5.1; 
 
out-type=application; out-subtype=ddif; out-mode=block; 
 
command="CONVERT/DOCUMENT 'INPUT_FILE'/FORMAT=WORDP 'OUTPUT_FILE'/FORMAT=DDIF"
 


Available Parameters

The rule parameters currently provided are shown in TABLE 3-11. Parameters not listed in the table are ignored.

TABLE  3-11   Available Conversion Parameters
Parameter
Description

COMMAND  

Command to execute to perform conversion. This parameter is required; if no command is specified, the entry is ignored.  

DELETE  

0 or 1. If this flag is set, the message part will be deleted. (If this is the only part in a message, then a single empty text part will be substituted.)  

IN-A1-FORMAT  

Input A1-Format from enclosing MESSAGE/RFC822 part.  

IN-A1-TYPE  

Input A1-Type from enclosing MESSAGE/RFC822 part.  

IN-CHAN  

Input channel to match for conversion (wildcards allowed). The conversion specified by this entry will only be performed if the message is coming from the specified channel.  

IN-CHANNEL  

Synonym for IN-CHAN.  

IN-DESCRIPTION  

Input MIME Content-Description.  

IN-DISPOSITION  

Input MIME Content-Disposition.  

IN-DPARAMETER-DEFAULT-n  

Input MIME Content-Disposition parameter value default if parameter is not present. This value is used as a default for the IN-DPARAMETER-VALUE-n test when no such parameter is specified in the body part.  

IN-DPARAMETER-NAME-n  

Input MIME Content-Disposition parameter name whose value is to be checked; n = 0, 1, 2, ....  

IN-DPARAMETER-VALUE-n  

Input MIME Content-Disposition parameter value that must match corresponding IN-DPARAMETER-NAME (wildcards allowed). The conversion specified by this entry is only performed if this field matches the corresponding parameter in the body part's Content-Disposition: parameter list.  

IN-PARAMETER-DEFAULT-n  

Input MIME Content-Type parameter value default if parameter is not present. This value is used as a default for the IN-PARAMETER-VALUE-n test when no such parameter is specified in the body part.  

IN-PARAMETER-NAME-n  

Input MIME Content-Type parameter name whose value is to be checked; n = 0, 1, 2, ....  

IN-PARAMETER-VALUE-n  

Input MIME Content-Type parameter value that must match corresponding IN-PARAMETER-NAME (wildcards allowed). The conversion specified by this entry is performed only if this field matches the corresponding parameter in the body part's Content-Type: parameter list.  

IN-SUBJECT  

Input Subject from enclosing MESSAGE/RFC822 part.  

IN-SUBTYPE  

Input MIME subtype to match for conversion (wildcards allowed). The conversion specified by this entry is performed only if this field matches the MIME subtype of the body part.  

IN-TYPE  

Input MIME type to match for conversion (wildcards allowed). The conversion specified by this entry is only performed if this field matches the MIME type of the body part.  

ORIGINAL-HEADER-FILE  

0 or 1. If set to 1, the original headers or the enclosing MESSAGE/RFC822 part are written to the file represented by the OUTPUT_HEADERS symbol.  

OUT-A1-FORMAT  

Output A1-Format.  

OUT-A1-TYPE  

Output A1-Type.  

OUT-CHAN  

Output channel to match for conversion (wildcards allowed). The conversion specified by this entry will be performed only if the message is destined for the specified channel.  

OUT-CHANNEL  

Synonym for OUT-CHAN.  

OUT-DESCRIPTION  

Output MIME Content-Description if it is different than the input MIME Content-Description.  

OUT-DISPOSITION  

Output MIME Content-Disposition if it is different than the input MIME Content-Disposition.  

OUT-DPARAMETER-NAME-n  

Output MIME Content-Disposition parameter name; n=0, 1, 2, ....  

OUT-DPARAMETER-VALUE-n  

Output MIME Content-Disposition parameter value corresponding to OUT-DPARAMETER-NAME-n.  

OUT-MODE  

Mode in which to read the converted file. This should be one of: BLOCK, RECORD, RECORD-ATTRIBUTE, TEXT.  

OUT-ENCODING  

Encoding to apply to the converted file.  

OUT-PARAMETER-NAME-n  

Output MIME Content-Type parameter name; n = 0, 1, 2, ....  

OUT-PARAMETER-VALUE-n  

Output MIME Content-Type parameter value corresponding to OUT-PARAMETER-NAME-n.  

OUT-SUBTYPE  

Output MIME type if it is different than the input MIME type.  

OUT-TYPE  

Output MIME type if it is different than the input type.  

OVERRIDE-HEADER-FILE  

0 or 1. If set, then headers are read from the OUTPUT_HEADERS symbol, overriding the original headers in the enclosing MESSAGE/RFC822 part.  

PARAMETER-SYMBOL-n  

Content-Type parameters to convert to environment variables if present; n = 0, 1, 2, .... Takes as argument the name of the MIME parameter to convert, as matched by an IN-PARAMETER-NAME-n clause. Each PARAMETER-SYMBOL-n is extracted from the Content-Type: parameter list and placed in an environment variable of the same name prior to executing the converter.  

PARAMETER-COPY-n  

A list of the Content-Type: parameters to copy from the input body part's Content-Type: parameter list to the output body part's Content-Type: parameter list; n=0, 1, 2, .... Takes as argument the name of the MIME parameter to copy, as matched by an IN-PARAMETER-NAME-n clause.  

PART-NUMBER  

Dotted integers: a. b. c... The part number of the MIME body part.  

RELABEL  

0 or 1. This flag is ignored during conversion channel processing.  


Predefined Environment Variables

TABLE 3-12 shows the basic set of environment variables available for use by the conversion command.

TABLE  3-12   Environment Variables used by Conversion Channel
Environment Variable
Description

INPUT_TYPE  

The content type of the input message part.  

INPUT_SUBTYPE  

The content subtype of the input message part.  

INPUT_DESCRIPTION  

The content description of the input message part.  

INPUT_DISPOSITION  

The content disposition of the input message part.  

OUTPUT_FILE  

The name of the file where the converter should store its output. The converter should create and write this file.  

OUTPUT_FILE  

The name of the file where the converter should store headers for an enclosing MESSAGE/RFC822 part. The converter should create and write this file.  

Additional environment variables containing Content-Type: information can be created as they are needed using the PARAMETER-SYMBOL-n facility.


Conversion Entry Scanning and Application

The conversion channel processes each message part-by-part. The header of each part is read and its Content-Type: and other header information is extracted. The entries in the conversion file are then scanned in order from first to last; any IN- parameters present and the OUT-CHAN parameter, if present, are checked. If all of these parameters match the corresponding information for the body part being processed, then the conversion specified by the remainder of the parameter is performed.

More specifically, the matching checks: if the IN-CHAN and OUT-CHAN parameters match the channels through which the message is passing; and if the PART-NUMBER matches the structured part number2 of the message part; and if all of the IN-CHAN, IN-PARAMETER-NAME, IN-PARAMETER-VALUE, IN-SUBTYPE, and IN-TYPE, parameters match the Content-Type: of the message; and if all of the IN-DISPOSITION, IN-DPARAMETER-NAME, and IN-DPARAMETER-VALUE parameters match the Content-Disposition of the message; and if the IN-DESCRIPTION matches the Content-Description of the message; and if the IN-SUBJECT, IN-A1-TYPE, and IN-A1-FORMAT of the headers of the immediately enclosing message (MESSAGE/RFC822 part) match those immediately enclosing the message part. Only if all specified parameters match is the entry consider to match. Scanning terminates once a matching entry has been found or all entries have been exhausted. If no entry matches no conversion is performed.

If the matching entry specifies DELETE=1, then the message part is deleted. Otherwise, the command specified by the COMMAND parameter is executed.

Once an entry with a COMMAND parameter has been selected the body part is extracted to a file. The converter execution environment is prepared as specified by the PARAMETER-SYMBOL-n parameters. Finally, a subprocess is created to run the command specified by the COMMAND parameter. The command should perform the necessary conversion operation, reading the file specified by the INPUT_FILE environment variable and producing the file specified by the OUTPUT_FILE environment variable.

Conversion operations are terminated and no conversion is performed if the forked command returns an error.

If the command succeeds, the resulting output file is read as specified by the OUT-MODE parameter and a new body part containing the converted material is constructed according to the OUT-ENCODING, OUT-PARAMETER-NAME-n, OUT-PARAMETER-VALUE-n, OUT-SUBTYPE, OUT-TYPE, OUT-DESCRIPTION, OUT-DISPOSITION, and OUT-DPARAMETER-VALUE-n parameters.

This process is repeated for each part of the message until all parts have been processed.


Headers in an Enclosing MESSAGE/RFC822 Part

When performing conversions on a message part, the conversion channel has access to the headers in an enclosing MESSAGE/RFC822 part, or to the message headers if there is no enclosing MESSAGE/RFC822 part.

For instance, the IN-A1-TYPE and IN-A1-FORMAT parameters can be used to check the A1-Type and A1-Format headers of an enclosing part, and the OUT-A1-TYPE and OUT-A1-FORMAT parameters can be used to set those enclosing headers.

More generally, if an entry is selected that has ORIGINAL-HEADER-FILE=1, then all the original headers of the enclosing MESSAGE/RFC822 part are written to the file represented by the OUTPUT_HEADERS environment variable. If OVERRIDE-HEADER-FILE=1, then the conversion channel will read and use as the headers on that enclosing part the contents of the file represented by the OUTPUT_HEADERS environment variable.


Environment Variable Substitution in Conversion Entries

Environment variable names may be substituted into a conversion entry by enclosing the name in single quotes. For instance, with a site supplied command procedure CONVERTER that attempts to perform various conversions and which defines OUTPUT_TYPE and OUTPUT_SYMBOL job logicals describing its output, one might use an entry along the lines of:

 
in-chan=tcp_local; out-chan=l; in-type=application; in-subtype=*; 
 
out-type='OUTPUT_TYPE'; out-subtype='OUTPUT_SUBTYPE';
 
command="@CONVERTER 'INPUT_FILE' 'OUTPUT_FILE' 'INPUT_TYPE' 'INPUT_SUBTYPE'"
 

To obtain a literal single quote in a conversion entry, quote it with the backslash character, \'. To obtain a literal

backslash in a conversion entry, use two backslashes, \\.


Calling Out to a Mapping Table from a Conversion Entry

The value for a conversion parameter may be obtained by calling out to a mapping table. The syntax for calling out to a mapping table is as follows:

 
'mapping-table-name:mapping-input'
 

Consider the following mapping table:

 
X-ATT-NAMES 
 
postscript            PS.PS 
 
wordperfect5.1        WPC.WPC 
 
msword                DOC.DOC
 

The following conversion entry for the above mapping table results in substituting generic file names in place of specific file names on attachments:

 
out-chan=tcp_local; in-type=application; in-subtype=*; 
 
in-parameter-name-0=name; in-parameter-value-0=*:[*]*; 
 
  out-type=application; out-subtype='INPUT-SUBTYPE'; 
 
  out-parameter-name-0=name; 
 
  out-parameter-value-0='X-ATT-NAMES:\'INPUT_SUBTYPE\'' 
 
  command="COPY 'INPUT_FILE' 'OUTPUT_FILE'"
 




Copyright © 1999 Sun Microsystems, Inc. All Rights Reserved.