Make a current backup of the old Mac onto the external drive. This can be a Time Machine backup, or a bootable clone backup made with the help of (an old version of) Carbon Copy Cloner or SuperDuper!
This should be straightforward if the hard drive on your iMac is healthy.
Since the version of macOS running on the old Mac predates APFS, you will need to format the drive as Mac OS Extended (journaled, non-case-sensitive) for the migration. After you do the migration AND you are certain that things went well, you can reformat the drive as APFS (non-case-sensitive). (The version of Time Machine on the new Mac prefers to back up to APFS-formatted drives, regardless of whether they are HDDs or SSDs.)
Transfer the external drive containing the backup to the M4 Mac mini and point Migration Assistant at it. You will need to compensate for the difference in USB connectors (the old Mac has USB-A, the new one has USB-C), but there are many ways of doing that. E.g., you can use Apple's USB-C to USB adapter; or, if the drive is a portable one with a Micro USB 3.0 B socket and Micro USB 3.0 B to USB-A cable, you can get a Micro USB 3.0 B to USB-C cable.
Notes:
I'm assuming that the M4 Mac mini has a large enough drive to migrate everything from the old Mac. If it does not, you may need to tell Migration Assistant to exclude some categories of data (like Pictures and Music), and then manually migrate that stuff to an external drive.
Due to the huge jump from El Capitan to Sequoia or Tahoe, you may encounter some issues in migrating your iTunes Library and/or iPhoto/Photos Library. This is one good reason NOT to erase the backup of the old Mac (to reuse the drive) until you have checked that everything transferred OK,