Assuming you are using 10.5, go to your mail preferences. Click on Accounts and the account you want to edit. Go to advanced and you will see Port. IMAP is 143 or 993 (secure connection) and POP3 is 110 and 995 (secure). To change the port for your SMTP connection, under the account you want to edit, go to Account Information and in the outgoing drop-down you will see edit server list. There you can edit the ports in the Advanced tab in the window that pops up.