Author Topic: smtp host for each user  (Read 1978 times)

obimichael

  • Zen Apprentice
  • *
  • Posts: 18
  • Karma: +1/-0
    • View Profile
smtp host for each user
« on: November 29, 2010, 08:11:11 »
Hi!
I think it would be a nice feature, if it is possible to define a smtp-server (smarthost/relayhost) for every user in the user corner.

For example user1 is using gmail, user2 a hotmail account and user3 a yahoo account. So it is possible to use webmail or groupware to send emails with the external mail account.

I allready configured postfix and the main.cf.mas to act as a relayhost and every user can use his own external mailaccount . I wrote a small php and shell script to administrate ...

* internal mail address
* external mail address
* smtp-server
* smtp-port
* external username
* external password

It wasn't very tricky and it is working fine with sogo, but not really nice layout. I think it will be a nice feature if it is possible to administrate the smtp-server within the user corner.

Regards
Michael

christian

  • Zen Hero
  • *****
  • Posts: 3666
  • Karma: +83/-14
    • View Profile
Re: smtp host for each user
« Reply #1 on: December 07, 2010, 02:27:34 »
+1

Current implementation is mixing MTA amd MDA. Thus there is no "mailhost" option in LDAP for users entry  :(

aleksc

  • Zen Apprentice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: smtp host for each user
« Reply #2 on: March 03, 2011, 01:10:57 »
Hi!
I think it would be a nice feature, if it is possible to define a smtp-server (smarthost/relayhost) for every user in the user corner.

For example user1 is using gmail, user2 a hotmail account and user3 a yahoo account. So it is possible to use webmail or groupware to send emails with the external mail account.

I allready configured postfix and the main.cf.mas to act as a relayhost and every user can use his own external mailaccount . I wrote a small php and shell script to administrate ...

* internal mail address
* external mail address
* smtp-server
* smtp-port
* external username
* external password

It wasn't very tricky and it is working fine with sogo, but not really nice layout. I think it will be a nice feature if it is possible to administrate the smtp-server within the user corner.

Regards
Michael

Hello Michael,

im interested on how you were able to modify postfix to relay mail to external accounts. 

we have local email (e.g. name@company.local) which we use as an internal email.  and all of us have individual gmail accounts which we can retrieve using zarafa.  what we have at the moment is the ability to retrieve email from gmail, but not able to reply back.  can you teach me how to modify postfix and be able to send email through gmail via zentyal?  i have already tried countless of tutorials for postfix in the internet and almost all of them are teaching the same thing.  once i do it for a single user account, it works.  but when i do a sender dependent relay mapping, it won't work anymore.

i would really appreciate if you could teach me to do this please.

thank you.

aleksc  :-[

obimichael

  • Zen Apprentice
  • *
  • Posts: 18
  • Karma: +1/-0
    • View Profile
Re: smtp host for each user
« Reply #3 on: March 03, 2011, 03:00:46 »
Hello!
I will try to explain my steps.

1.) EBox -> Mail -> General,
Smarthost to send mail: you can insert any name for example "not.used.yet".
Smarthost authentication: insert Username & Password, will not be used either, you can insert what you want!

2a.) backup /usr/share/ebox/stubs/mail/main.cf.mas
2b.) edit /usr/share/ebox/stubs/mail/main.cf.mas
I changed the main.cf.mas, try to find the line: relayhost = <% $relay %> and then I changed the following lines to ...

Code: [Select]
#201012 ---- relayhost = <% $relay %>
 
% if ($zarafa) {
transport_maps = hash:/etc/postfix/transport
zarafa_destination_recipient_limit = 1
% }
 
% if ($relay) {
#201012 --- smtp_tls_security_level = may
smtp_tls_security_level = none
smtp_tls_key_file  = <% $keyFile  %>
smtp_tls_cert_file = <% $certFile %>
 
#201012 ---
sender_canonical_maps = hash:/etc/postfix/sender_canonical
sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relayhost
 
% }
 
% if ($relayAuth) {
smtp_sasl_auth_enable = yes
#201012 --- smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sender_passwd
smtp_sender_dependent_authentication = yes

% }

3.) create files
/etc/postfix/sender_passwd
/etc/postfix/sender_relayhost
/etc/postfix/sender_canonical

4.) sender_passwd looks like
Code: [Select]
email1@extern.com   extern_smtp_username:extern_smtp_password
email2@extern.xxx   extern_smtp_username2:extern_smtp_password2

5.) sender_relayhost looks like
Code: [Select]
email1@extern.com   [extern_smtp_server:extern_smtp_port]
email2@extern.xxx   [extern_smtp_server2:extern_smtp_port2]

6.) sender_canonical looks like
Code: [Select]
name@company.local   email1@extern.com
name2@company.local   email2@extern.xxx

7.) convert the files with postmap
Code: [Select]
postmap sender_canonical
postmap sender_relayhost
postmap sender_passwd

8.) change sth at EBox -> Mail -> General for example smarthost authentication and then save the changes, so the edited main.cf.mas is used and postfix is restarted. If you have applied the changes once, and you add a new Email Address you only have to convert the files again and  restart postfix.

9.) Be careful: If an update for the mail modul is available, the script can loose all modifications and you have to edit the main.cf.mas again.


No warrenty, but this works for me ...
« Last Edit: March 03, 2011, 03:12:39 by obimichael »

sixstone

  • Zentyal Staff
  • Zen Hero
  • *****
  • Posts: 1375
  • Karma: +17/-0
    • View Profile
    • Sixstone's blog
Re: smtp host for each user
« Reply #4 on: March 05, 2011, 02:05:49 »
Thanks very much for your addition obimichael!!  ;D

It is really appreciated!
My secret is my silence...

Zentyal Cloud Software Architect

kg66

  • Zen Apprentice
  • *
  • Posts: 32
  • Karma: +2/-0
    • View Profile
Re: smtp host for each user
« Reply #5 on: March 14, 2011, 11:48:03 »
+1
would be nice if the steps 4 to 6 can be set in the user corner,

by the way: great contribution, obimichael!!

moazrefat

  • Zen Apprentice
  • *
  • Posts: 36
  • Karma: +0/-0
    • View Profile
Re: smtp host for each user
« Reply #6 on: November 27, 2012, 02:50:54 »
thanks very much obimichael , testing in progress & that is exactly what i need to do ,
i hope i got a success try .


thank you again Man