Fixing Invalid File Type text/x-pascal When Importing Contacts to Mautic

Mautic Error File Type text/x-pascal

If you get the following error when trying to import contacts into Mautic, it's likely that the issue is not with the file encoding, but with one of the fields within the file.

Invalid file type "text/x-pascal". Use a file that matches of of the following mime types: "text/csv", "text/plain".

The error comes from PHP fileinfo mime-type detection of the uploaded file rather than an issue with Mautic itself. I have personally seen the problem on PHP 5.6, but not on PHP 7, so it may just be specific to older versions.

Words known to trigger the issue are:

  • program
  • record

That can be the contents of a cell or part of a string such as 'programmer'.

After a few tests, I found that you can get PHP to recognise the correct mime-type by making sure all cells in the csv are quoted rather than just comma separated (Or whichever delimiter you are using).

If you use OpenOffice then there is an option when saving the file to 'quote all text cells'. This wraps each string in quotes and seems to negate the issue.

OpenOffice quote all text cells

Other spreadsheet programs no doubt have a similar option.