I think you first need a mailserver, then you'd use imapsync (for example) to move the mailbox initially, and then periodically fetch the mails from gmail.
For outgoing mail you can either configure your mailserver to relay mail via your gmail account. Or configure your mail program to send mail directly via gmail.