Accessing Apple Mail's mailboxes remotely, maybe over SSH?
What I would do is first make sure you're using IMAP to connect to your email (which should be the case anyhow —— I can't think of any good reasons to use POP), then use a terminal email client such as Alpine or Mutt, both of which are easily installed with Mac Ports or Homebrew, or built yourself. 

This way, all your email will be perfectly synchronized, with iPhone, webmail, Mac Mail, Alpine, etc