Yes, just make sure to check the ssl button and use the server name – all you need to remember is that Gmail uses a specific folder structure when viewed with an IMAP client. Instead of INBOX.foldername, it does something like

[GMAIL]/foldername. We have taken this into account and it will let you migrate it anyways, creating a new folder as needed on your new mail server.