The root of the issue is you need an IMAP client that can access two mailboxes at the same time. I don't know about others, but Mozilla Thunderbird allows one to drag-and-drop folders and messages across IMAP accounts. An intermediate copy is still made in memory if not cached on disk.
There maybe tools to run from the command line. Running one from a DreamHost web server might take a while and/or consume resources not serving web sites to do so; I suggest you consider running a tool or full-featured client from your own machine.