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

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
reference:attachment_processing_script [2018/06/28 10:04] paulreference:attachment_processing_script [2022/11/24 09:28] paul
Line 12: Line 12:
  
 ====NeedsRecode==== ====NeedsRecode====
-function NeedsRecode(filtervariables, attachments_array, mime_structure)+  function NeedsRecode(filtervariables, attachments_array, mime_structure)
  
 Called when VPOP3 is about to process a message 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+  * returns True if the Lua script wants to alter any of the attachments of the whole message
  
 ====NeedsRewrite==== ====NeedsRewrite====
-function NeedsRewrite(attachmentname, MIMEtype, filtervariables)+  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) 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+  * 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