User Tools

Site Tools


reference:attachment_processing_script

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
reference:attachment_processing_script [2018/06/28 09:41] – created paulreference:attachment_processing_script [2022/11/24 09:28] paul
Line 11: Line 11:
   * RewriteAttachment   * RewriteAttachment
  
 +====NeedsRecode====
 +  function NeedsRecode(filtervariables, attachments_array, mime_structure)
 +
 +Called when VPOP3 is about to process a message
 +
 +  * returns True if the Lua script wants to alter any of the attachments of the whole message
 +
 +====NeedsRewrite====
 +  function NeedsRewrite(attachmentname, MIMEtype, filtervariables)
 +
 +Called when VPOP3 is about to process an attachment in a message (Only called if 'NeedsRecode' returned true, or there is some other reason for VPOP3 to process attachments, eg to remove/rename an attachment due to Attachment Filtering)
 +
 +  * returns True if the Lua script wants to rewrite/rename the attachment
 +
 +====GetRename====
 +  function GetRename(type, attachmentName, MIMEtype, filterVariables)
 +
 +  * type = MIME or UUENCODE
 +
 +  * returns two values, the first is the new filename, the second is the new MIME type (eg 'text/plain', 'image/jpeg', etc)
 +
 +====GetContentDispositionLine====
 +  function GetContentDispositionLine(originalContentDispositionLine, type, attachmentName, rewriteSection, MIMEtype, filterVariables)
 +
 +  * type = MIME
 +  * rewriteSection = true if the MIME section will be rewritten (eg because of 'NeedsRewrite' function)
 +
 +  * returns new Content-Disposition MIME header line
 +
 +====IsLockNeeded====
 +  function IsLockNeeded(originalFileName, newFileName, originalAttachmentName, MIMEtype)
 +
 +  * returns True if a critical section is required around the 'RewriteAttachment' function call (so it is not called multiple times in parallel)
 +
 +==RewriteAttachment====
 +  function RewriteAttachment(originalFileName, newFileName, originalAttachmentName, MIMEtype, filterVariables)
 +  
 +Called to give the script a chance to rewrite the attachment. The original attachment is stored in the file 'originalFileName'. The script should write the new attachment to 'newFileName'.
 +
 +Note that whether or not this function alters the attachment, the attachment data in the message is rewritten using Base64 encoding, so if the original attachment was stored using a different encoding (eg Quoted-Printable) then the message will be changed. 'NeedsRewrite' should return False if you want the message to stay unaltered.
 +
 +  * returns True if the attachment has actually been rewritten. If not, the original one is used. 
 +  * 
reference/attachment_processing_script.txt · Last modified: 2022/11/24 09:29 by paul