Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Administrators

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-26-2011, 03:25 AM
Starter Member
 
Posts: 2
Default [SOLVED] Send mails from external account trough Zimbra

Hi all,

I'm fairly new to Zimbra but managed to install the ZCS community edition 7.0.0_GA_3077 on Ubuntu 10.04 Server. Sending and receiving mails works just fine.

My Problem:
It is quite easy to get Zimbra to fetch mails from external mail accounts (via POP3 or IMAP) but in addition to that I would like to send mails "from" these external accounts.

My Zimbra account: me@mydomain.com
Some external account: me@somedomain.com

I set up postfix as described in this post [SOLVED] multiple accounts on smtp relay
By doing this postfix can send outgoing mails to different relay servers depending on the mail address they originate from. I verified this using telnet (localhost port 25) on the Zimbra server. Works great, meaning if I send a mail from me@somedomain.com postfix automatically relays it to smtp.somedomain.com instead of sending it to the default relay server of my domain hoster.

But if I send a mail using the Zimbra Web-Client and choose an external account as the origin of my mail (e.g. me@somedomain.com) Zimbra substitutes the "from" address of my mail for the address of my Zimbra account (me@mydomain.com). This causes postfix NOT to send the mail to the "right" relay host. BTW I already checked "Allow sending email from any address" in the preferences.

Is it somehow possible to prevent Zimbra from substituting the "from" so that postfix could route the mail to the right relay host? I'm very grateful for any pointers!

Tanks in advance!
Benjamin

EDIT:
Found solution here Bug 40731 – Wrong MAIL FROM in SMTP dialog when using a Persona

Quote:
SMTP behavior now switches based on the value of
zimbraSmtpRestrictEnvelopeFrom. When it's set to TRUE, we force
MAIL FROM in the SMTP session to be the address of the account.
When it's set to FALSE, MAIL FROM is set to either the Sender or
From header value in the outgoing message, in that order.
zmprov mc default zimbraSmtpRestrictEnvelopeFrom FALSE

Last edited by fleiben; 02-26-2011 at 05:04 AM.. Reason: Found solution
Reply With Quote
  #2 (permalink)  
Old 03-20-2011, 06:49 AM
Intermediate Member
 
Posts: 21
Default

You say:

My Problem:
It is quite easy to get Zimbra to fetch mails from external mail accounts (via POP3 or IMAP) but in addition to that I would like to send mails "from" these external accounts.


Can you explain how you have set this up. I need to do this for all mail to my users that is sent to external mail domain. Then fetch this mail and disctibute to the local mail users on my non routable local zimbra mail domain. I have been stuck onthis point for a number of years, so have not been able to migrate to zimbra without this capability.

Cheers
Stephen
Reply With Quote
  #3 (permalink)  
Old 03-20-2011, 10:07 AM
Starter Member
 
Posts: 2
Default

Hi Stephen,

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:
Code:
zmprov mc default zimbraDataSourcePollingInterval 5m
This would result in zimbra polling your external accounts every five minutes.

As an alternative there are some posts suggesting to use fetchmail to accomplish the same.

Sending "external" mails:
STEP 1
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.

STEP 2
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
Code:
zmprov mc default zimbraSmtpRestrictEnvelopeFrom FALSE
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.

STEP 3
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
Code:
external-user1@external-domain1.com [smtp.external-domain1.com]:port1
external-user2@external-domain2.com [smtp.external-domain2.com]:port2
external-user3@external-domain3.com [smtp.external-domain3.com]:port3
...
(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
Code:
external-user1@external-domain1.com smtp-username1:smtp-password1
external-user2@external-domain2.com smtp-username2:smtp-password2
external-user3@external-domain3.com smtp-username3:smtp-password3
...
Then need to enter the login information for your default relay MTA you specified in STEP 2 in the following form
Code:
default-smtp-server:port default-smtp-username:default-smtp-password
The forum post I referred to above suggests using the form
Code:
[default-smtp-server]:port default-smtp-username:default-smtp-password
but this did not work for me.

You need to run the following commands to enable sender dependent authentication (again as user zimbra)
Code:
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

postmap /opt/zimbra/conf/relayhost_map
postmap /opt/zimbra/conf/relay_password
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.

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
Code:
postconf -e smtp_cname_overrides_servername=no
postconf -e smtp_use_tls=yes
After you are done editing the postfix system it needs to be reloaded
Code:
postfix reload
STEP 4
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.

Regards,
Benjamin
Reply With Quote
  #4 (permalink)  
Old 03-20-2011, 02:38 PM
Intermediate Member
 
Posts: 21
Default

Thanks for thi. I will need to work through this. Todau I have installed zcs 7 twice from scratch.

Cheers
Stephen
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.