I have a new imac with Lion. How can I transfer my imap mail from my older imac with 10.5.8?
In the IMAP protocol, all E-Mails are stored and managed on the server. This allows multiple clients on different computers to manage the same mailbox.
By default, the Mail.app in OSX Lion also stores Drafts, Notes and Sent Messages on the server.
Just setup your mail account in System Preferences → Mail, Contacts & Calendars and you should be fine. Your E-Mails will be downloaded from the server.
You can use the Migration Assistant to import data from another Mac. It can transfer important information, such as user accounts, applications, network and computer settings, and files, from one Mac computer to another via a FireWire cable, ThunderBolt cable, or via an Ethernet or wireless network.
P.S. As @gentmatt points out, for IMAP-based accounts you don’t need to transfer anything. Just set up your account and it will start downloading your messages. If you’d rather not re-download your entire mail archive, I’d recommend using the Migration Assistant though.