BlogComparisons · November 23, 2026 · 6 min read

Contact Form 7 Attachment Types: file-type vs python-magic vs Apache Tika vs Mime-Detective vs Symfony Mime

Compare five content-type detection libraries for a custom attachment handoff, including runtime dependencies, unknown results and definition licensing.

Five document cards with media symbols sit above a sorting tray beneath a magnifying glass.
Generated conceptual illustration.

An attachment reaching a Contact Form 7 workflow has several descriptions: its filename extension, the media type supplied during upload and the type inferred from its contents. Those descriptions can disagree. A custom worker moving a document into a CRM or preview service needs a policy for that disagreement before choosing a parser.

file-type, python-magic, Apache Tika, Mime-Detective and Symfony Mime offer different ways to obtain content-type evidence. This is a documentation-based comparison checked on November 23, 2026, not a detection benchmark. None is presented as a native CF7 connector, malware scanner or guarantee that a file is valid. This site publishes CF7 Analytics; attachment inspection is a separate custom workflow.

Compare runtime, scope and licensing

The following costs concern the software components, not a managed inspection service. Deployment, maintenance and any separately licensed definitions remain part of the decision. Keep the exact installed release and definition set in the worker’s record.

Product Runtime and approach Core terms and cost Decision boundary
file-type JavaScript, binary signatures MIT, no library license fee Not a general text-format detector
python-magic Python wrapper for libmagic MIT plus included notices; native dependency separate Package and database availability matter
Apache Tika Java toolkit for detection and extraction Apache 2.0, no core license fee Choose detection or parsing deliberately
Mime-Detective .NET signature inspection Modified MIT-based terms; definition packs differ Expanded commercial definitions need separate rights
Symfony Mime PHP MIME utilities and guessers MIT, no component license fee Inspect file contents rather than mapping an extension

file-type

file-type fits a JavaScript worker that receives binary files or streams and needs an initial type hint. Its API returns an extension and MIME type when a supported signature matches, and can return no match. The project uses ESM, which is a packaging consideration for an existing CommonJS integration.

Strengths: the focused interface makes it straightforward to insert a detection step before selecting a PDF or image processor. A Node service can record the detected type alongside an inquiry reference without building a separate document-analysis service. The core is MIT-licensed.

Limitations: upstream explicitly focuses on binary formats, excluding general recognition of text formats such as CSV and SVG. Signature detection is a best-effort hint, not proof that a document is complete or safe to parse. An unknown result must have its own outcome rather than inheriting the extension’s apparent certainty.

CF7 fit: choose it for an existing Node handoff with a narrow binary allowlist. Send a mismatch to review and keep the original bytes unchanged. For accepted formats, the next format-specific processor still needs its own validation and resource limits.

python-magic

python-magic exposes libmagic to Python. It can inspect a file or a buffer and return a MIME-oriented result. This suits an existing Python worker that already performs attachment reconciliation, because the detector can run close to the code selecting the next processing step.

Strengths: libmagic’s definition database supplies the recognition behavior, while the wrapper provides a small Python interface. The wrapper license uses MIT terms with additional included notices. There is no per-inquiry license fee for the wrapper itself.

Limitations: installing the Python package is not the entire deployment. The native library and its database must also be available on the target system. Different installations can therefore produce different descriptions. Pin and record the dependency versions used for an operational decision; do not compare free-text descriptions as though they were permanent business identifiers.

CF7 fit: prefer it when the team already maintains libmagic in the worker environment. Test ordinary allowed files, truncated input and misleading extensions there. Use MIME results through an explicit normalization policy, preserving an unknown category when the result cannot support a confident routing decision.

Apache Tika

Apache Tika is a broader content-analysis toolkit that detects types and extracts text and metadata. It is a candidate when the attachment workflow will later need document contents for a reviewed search or classification process, not merely a label for a handful of file formats.

Strengths: a Java-based integration can use a common toolkit for multiple document families. Its Apache 2.0 license does not impose a core per-file fee. Separate dependencies, deployment choices and any optional external services still need review.

Limitations: detection and full parsing are different operations. Do not turn on every extraction path simply because the first requirement is to identify a PDF. The current site distinguishes its 4.x documentation from the supported 3.x line; match implementation instructions to the installed release rather than combining configuration examples from both.

CF7 fit: consider Tika when a maintained Java service or private document-processing service already exists. Keep the handoff bounded and report detection separately from extraction success. A recognizable media type does not prove that text extraction will succeed, and extracted text should not automatically enter public analytics.

Mime-Detective

Mime-Detective offers signature inspection for .NET, with Minimal, Condensed and Exhaustive definition choices. It can inspect bytes, streams or files and group results by extension or MIME type. The selected definition pack is a substantive configuration choice, not just an installation detail.

Strengths: a .NET team can choose a limited set of definitions for the document families its intake accepts, rather than treating broader coverage as automatically better. Upstream says the Minimal definitions require no additional licensing for use.

Limitations and cost: the core license is modified MIT-based text with an extra restriction on distributing derivative packages through package-management systems. Do not label it plain MIT. The definition documentation separately identifies commercial licensing for the TrID-derived Condensed and Exhaustive packs. Obtain current terms and a quote for the intended commercial use rather than treating a free download as unrestricted permission.

CF7 fit: choose it for a maintained .NET attachment worker after deciding which definitions and rights apply. Preserve ambiguous results for a policy decision instead of silently selecting the most convenient extension.

Symfony Mime

Symfony’s MIME type utilities fit a PHP integration that needs extension mappings and content-based guesses in its existing runtime. Those are separate operations. Looking up the MIME types associated with a filename extension does not inspect the uploaded file.

Strengths: guessMimeType provides a clear content-inspection entry point. The component can use supported guessers, including Fileinfo, and permits custom guessers. Its MIT license has no component license fee. An existing PHP service may find this easier to operate than introducing another language solely for detection.

Limitations: the host must provide the capabilities used by the selected guesser. Inspect the effective PHP environment and choose a supported component release compatible with it. Installing a standalone component does not install a CF7 hook, preserve temporary uploads or supply a complete attachment policy.

CF7 fit: prefer it when a reviewed PHP worker owns the handoff. Keep content guessing, extension comparison and final allowlist decisions explicit. Route a null or unexpected result to a defined failure path instead of allowing the filename to override it.

Choose using a small acceptance corpus

Build harmless fixtures representing accepted types, unknown input, renamed extensions and damaged files. Record the bytes, detector release, definition version and expected policy outcome. The useful comparison is whether the complete workflow makes a reproducible decision, not which library recognizes the largest advertised catalog.

Choose file-type for a focused Node binary workflow, python-magic for an established Python/libmagic environment, Tika for broader maintained document processing, Mime-Detective for .NET with reviewed definition rights, or Symfony Mime for an existing PHP service. Keep file retention separate: our temporary upload guide explains why a background worker cannot rely on a transient CF7 path.

For submission trends, consult the free Svetlik Analytics listing. A trend dashboard does not establish attachment validity, storage or delivery. The official project documentation and license links above support this comparison; verify the exact package you plan to deploy.