Adding a "Has Attachment" header
Drew Morris
drew at drewmorris.com
Thu Jan 27 14:19:37 GMT 2011
Hi All...
I am working on a custom delivery script that is used after MailScanner has already run. The script uses many of the headers that MailScanner and Spamassassin insert to determing proper delivery (think procmail).
I have the need to determine whether a message has attachments or if it is just simply text and html body parts without any attachments.
I can use code like this to do it I believe:
if ( $msg->isMultipart ) {
foreach my $part ( $msg->parts ) {
if ( $part->contentType eq 'text/html' ) {
# and do a count because more than 1 means 1 is an attachment
}
elsif ( $part->contentType eq 'text/plain' ) {
# and do a count because more than 1 means 1 is an attachment
}
else {
# Means there are attachments right?
}
}
}
But it seems like an unneccessarily heavy approach since MailScanner has already parsed and analyzed the message prior to this step. The ideal solution for me would be to have a configuration line MailScanner.conf that would allow me to turn on "AddAttachmentsCheckToHeader" or something like that and MailScanner could add a header like: X-MailScanner-HasAttachments: Yes or something similar. I don't think this would take much to do and I don't think it would require much (if any) additional overhead for MailScanners processing since it already has the message parsed.
Something like this would be very useful to a number of applications that custom deliver mail based on different attributes that they need to parse from the header so I don't think this is just something that would benefit my use-case.
Any thoughts would be greatly appreciated and if there is already a way to do this that I am just missing... please let me know.
Thanks,
Drew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.mailscanner.info/pipermail/mailscanner/attachments/20110127/55db4e97/attachment.html
More information about the MailScanner
mailing list