Most mail servers store emails either in "Mail Folders" or "Mail Dirs"
"Mail Folders" means that each folder/category has all the emails stored in it, one
after the other.
"Mail Dir" means each folder is actually a directory with each mail message represented
as a single file in that directory.
You are correct in saying if you get this mail file (which actually means Mail Folders or Mail Dirs, you can write a script to import it into your database.
As far as identifying the mail dirs/folders this is not something for you to do, its something for the "postmaster" at your domain to advise you, as they could be anywhere. Common places (on Unix Systems) include /var/spool/mail and ~mail - but this is arbitrary.
An alternative to getting the mail folder/dir would be to instruct the server to provide it to you. Depending on your scenario, if you have all the emails sitting in your inbox and your provider uses the "POP3" protocol, you should be able to script a mechanism to pull each mail down and process it. POP3 is quite a simple protocol to speak. You can do something similar with IMAP - which will give you access to all the files - but which is much harder to use and will posibly require a framework/library to help.
Mail Messages themselves are quite simple -
They consist of a header, separated by 2 lines and the body. You can parse the header to get the from, to, subject, date of the message etc. The body can be text or can be broken up into multiple sections, each typically Base64 encoded (but there are alternatives to this) - for example if you get an email with both HTML and text, or emails or attachments in the email.