I have only a few accounts on my zimbra server. My approach might not be optimal for a setup with many accounts.
Fetching external mails:
After you have created your zimbra accounts you can manually add external pop3 or imap accounts for each of those zimbra accounts. I guess this can be done in terminal if you have to setup many accounts. I logged into each zimbra account (zimbra web client) went to "Preferences" > "Accounts" to create external accounts. But I guess you already figured this out yourself.
Because zimbra did only poll external mails when I pressed the "Fetch external Mails"-button in the web client I had to run the following command in terminal as user zimbra:
This would result in zimbra polling your external accounts every five minutes.
zmprov mc default zimbraDataSourcePollingInterval 5m
As an alternative there are some posts suggesting to use fetchmail to accomplish the same.
Sending "external" mails:
This is a bit more tricky. First of all you need to add the external mail addresses to the corresponding zimbra accounts. This can be done in the admin console. Edit each account and go to the "Preferences" tab. There should be a text field labeled "only allow sending mail from the following addresses" (or something like that). Add all external addresses of your zimbra account and save your changes. It is important that you do not check the checkbox "allow sending mails from all addresses" above the text field. This could lead to major security problems in this setup.
Next you need to edit the MTA settings of your server. In the Admin Console go to "Managing Servers" and then the MTA tab. There should be a text field "Relay MTA for external delivery". There you need to enter the "default" smtp server (and port) you want to send your mails through. The downside of this is that from now on everyone on your server is able to send mails through this smtp server. Since most smtp servers replace the "from" address with the one you use to authenticate yourself against the smtp server everyone on your zimbra server could possibly send mails from this account. I'm not sure if there is a way around it at least I did not find a easy one. One possible solution could be to use a nonexistent MTA Relay server. Since every zimbra user will send his mails using his or her own smtp settings (server, username and password) this might work. BTW it won't work to leave the field empty because zimbra would then attempt to deliver the mails itself (not using any relay smtp server).
On the same tab uncheck the checkbox "Enable DNS lookups".
Save your changes.
Run the following command from terminal as user zimbra
This command is very important because otherwise zimbra would replace the "from" address of outgoing mails with the zimbra account name (and local domain) the mail is sent from. Setting zimbraSmtpRestrictEnvelopeFrom to FALSE allows a zimbra user to send mails from each address you specified (for this user) in STEP 1.
zmprov mc default zimbraSmtpRestrictEnvelopeFrom FALSE
The next and last step would be to modify postfix. This depends in large parts on your requirements and your smtp relay provider.
Have a look at the following forum post by mirkoguidolin
multiple accounts on smtp relay
Create the file /opt/zimbra/conf/relayhost_map and enter all external mail addresses for all your zimbra accounts in the form
(port is optional)
Create the file /opt/zimbra/conf/relay_password and enter the smtp login information for each external account of all your users in the following form
Then need to enter the login information for your default relay MTA you specified in STEP 2 in the following form
The forum post I referred to above suggests using the form
but this did not work for me.
You need to run the following commands to enable sender dependent authentication (again as user zimbra)
Each time you edit one of the files relayhost_map or relay_password you need to re-hash the file by running the appropriate portmap command from above.
postconf -e smtp_sender_dependent_authentication=yes
postconf -e sender_dependent_relayhost_maps=hash:/opt/zimbra/conf/relayhost_map
postconf -e smtp_sasl_auth_enable=yes
postconf -e smtp_sasl_password_maps=hash:/opt/zimbra/conf/relay_password
Depending on the authentication mechanism your provider uses you should have a look at the following wiki page
Enabling SMTP authentication
In my case I had to run the following commands
After you are done editing the postfix system it needs to be reloaded
postconf -e smtp_cname_overrides_servername=no
postconf -e smtp_use_tls=yes
Now you should be able to send mail from external mail addresses using the zimbra web client. Create a new mail and select an external account before you hit Send. If you want to send mails from a external mail address you did not add as an external account in the step "Fetching external mails" you can add a personality for this mail address to accomplish the same (web client > "Preferences" > "Accounts" > "Add Personality").
To debug the whole sending process I found the log file /var/log/zimbra.log quite useful. Here you can see which smtp relay server your outgoing mails are actually sent to and which "from" address is used.
I hope I could answer your questions or at least offer some pointers how this could be done.