Koozali.org: home of the SME Server

Custom .qmail Template Required for Single User - How?

Offline gundar

  • *
  • 25
  • +0/-0
Custom .qmail Template Required for Single User - How?
« on: July 21, 2009, 01:16:54 PM »
Hi

I am familiar with how templates hold eveything together and more so, how my little tweaks are overwritten by the reconfiguration and expansion programmes...

I have installed Zarafa.

I have a user who is info@domain.com and I would like to have this user only email redirected to a Public Folder. I have made this work, but when the .qmail file for this user is refreshed, all falls apart.

Can somebody help me modify/create a custom template which works for just the info@domain.com user?

Currently, the file /etc/e-smith/templates-user/.qmail/80Zarafa looks like this:


{
   my $zarafa = $user->prop('zarafa') || 'disabled';
   my $zarafa2 = ${'zarafa-server'}{GlobalForward} || 'disabled';
   return "| /usr/bin/zarafa-dagent -q $USERNAME ; if [ $? -ne 0 ] ; then exit -1; else exit 99; fi;"
           if ($zarafa eq 'enabled' || $zarafa2 eq 'enabled');
}


which produces the file /home/e-smith/files/users/info/.qmail which looks like this:

#------------------------------------------------------------
#              !!DO NOT MODIFY THIS FILE!!
#
# Manual changes will be lost when this file is regenerated.
#
# Please read the developer's guide, which is available
# at http://www.contribs.org/development/
#
# Copyright (C) 1999-2006 Mitel Networks Corporation
#------------------------------------------------------------


| condredirect info-junkmail headermatch 'X-Spam-Status: Yes'
# Forward not set
| /usr/bin/zarafa-dagent -q info ; if [ 0 -ne 0 ] ; then exit -1; else exit 99; fi;
./Maildir/



Which is as expected, however, I need just the info users .qmail file to look like this:

#------------------------------------------------------------
#              !!DO NOT MODIFY THIS FILE!!
#
# Manual changes will be lost when this file is regenerated.
#
# Please read the developer's guide, which is available
# at http://www.contribs.org/development/
#
# Copyright (C) 1999-2006 Mitel Networks Corporation
#------------------------------------------------------------


| condredirect info-junkmail headermatch 'X-Spam-Status: Yes'
# Forward not set
| /usr/bin/zarafa-dagent --public 'Public Folders\Info -C info ; if [ 0 -ne 0 ] ; then exit -1; else exit 99; fi;
./Maildir/


Thanks in advance all the gurus who share their knowledge here. By the way we are very pleased with Zarafa so far, it is a great Exchange replacement and the users have not noticed yet except for the subtle logos, speed improvment, accessbility and uptime;-)

Cheers


Gund


Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Custom .qmail Template Required for Single User - How?
« Reply #1 on: July 21, 2009, 01:44:33 PM »
hi

try this (NOT TESTED):

Code: [Select]
mkdir -p /etc/e-smith/templates-user-custom/.qmail

cp /etc/e-smith/templates-user/.qmail/80Zarafa /etc/e-smith/templates-user-custom/.qmail/

pico /etc/e-smith/templates-user-custom/.qmail/80Zarafa


and modify code this way:

Code: [Select]
{
   my $zarafa = $user->prop('zarafa') || 'disabled';
   my $zarafa2 = ${'zarafa-server'}{GlobalForward} || 'disabled';
   
    if ($zarafa eq 'enabled' || $zarafa2 eq 'enabled') {
    if ( $USERNAME ne 'info' ) {
return "| /usr/bin/zarafa-dagent -q $USERNAME ; if [ $? -ne 0 ] ; then exit -1; else exit 99; fi;";
}
else
{
return "| /usr/bin/zarafa-dagent --public 'Public Folders\Info' -C info ; if [ 0 -ne 0 ] ; then exit -1; else exit 99; fi;";
}
}

it should work

let us know

Ciao
Stefano
« Last Edit: July 21, 2009, 01:48:03 PM by Stefano a.k.a. nenonano »

Offline gundar

  • *
  • 25
  • +0/-0
Re: Custom .qmail Template Required for Single User - How?
« Reply #2 on: July 22, 2009, 03:34:39 AM »
Hi

I am very grateful for your help.

This is close, I am sure, but I am not a programmer, so there is something I cannot see which does not work as expected.

I did figure out:

signal-event email-update

is the process that creates the little .qmail files, so with that, I removed the old .qmail file and used the above line to recreate it (to see that it works). Then I modified the file you had me create above and tried it. No .qmail file was recreated at all. I even tried the other template:

/etc/e-smith/templates-user/.qmail/80Zarafa

Which produced no output, either . I guess if there was a syntax error in the script (and to me, it looks good), there would be a log file someplace.

I know you are dealing with somebody who is not a programmer at all, so I sympathise with you, I am an infrastructure guy and I deal with middle management all day, so I feel your pain. Please let me assure you that I do learn quickly and best by example, so your efforts to assist me are not in vain;-) I am grateful.

This little problem with Zarafa is fairly topical on the Zarafa forums, so I think a solution here will have a positive effect on traffic to this site and ultimately, SME Server.

Please could somebody help with either the syntax of the file (as above), or let me know where the output of the script goes so that I can troubleshoot this.

Again, thanks in advance for all help.


Gund

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Custom .qmail Template Required for Single User - How?
« Reply #3 on: July 22, 2009, 08:13:33 AM »
Quote
Please could somebody help with either the syntax of the file (as above), or let me know where the output of the script goes so that I can troubleshoot this.

open 2 console;
in the first type:
Code: [Select]
tail -f /var/log/messages
and hit [Enter]

in the other
Code: [Select]
signal-event email-update

you should see the error (if any) in the first console

Stefano

Offline byte

  • *
  • 2,183
  • +2/-0
Re: Custom .qmail Template Required for Single User - How?
« Reply #4 on: July 22, 2009, 05:44:56 PM »
Moving this topic to the SME 7.x contribs forum, it is more appropriate there. Thanks!
--[byte]--

Have you filled in a Bug Report over @ http://bugs.contribs.org ? Please don't wait to be told this way you help us to help you/others - Thanks!

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Custom .qmail Template Required for Single User - How?
« Reply #5 on: July 22, 2009, 06:29:29 PM »
Please could somebody help with either the syntax of the file (as above), or let me know where the output of the script goes so that I can troubleshoot this.

just tested on my test machine.. it works, but:
- you have to enable zarafa (see this)
- you have to change the line
Code: [Select]
return "| /usr/bin/zarafa-dagent --public 'Public Folders\Info' -C info ; if [ 0 -ne 0 ] ; then exit -1; else exit 99; fi;";

to
Code: [Select]
return "| /usr/bin/zarafa-dagent --public 'Public Folders\\Info' -C info ; if [ 0 -ne 0 ] ; then exit -1; else exit 99; fi;";

i.e. double \\

hth
Ciao
Stefano

Offline gundar

  • *
  • 25
  • +0/-0
Re: Custom .qmail Template Required for Single User - How?
« Reply #6 on: July 22, 2009, 10:49:17 PM »
Hi

As with a standard install, I have enabled the user, I assume this is not the case on your machine, perhaps you are not running Zarafa, so that would be required. But, just for the record, the 'info@...' user has a mailbox and received mail as usual.

You are right, the '\' will need to be a '\\' in this example as we are processing a script to produce the line and the '\' needs to be the output, right?

Okay, it still looks good, sorry I was not aware messages gets teh output of the template process, but I still get this:

Jul 23 08:42:38 server30 esmith::event[5842]: WARNING in /etc/e-smith/templates-user-custom//.qmail/80Zarafa: ERROR: Cannot process template /etc/e-smith/templates-user-custom//.qmail/80Zarafa: End of data inside program text that began at line 1

The complete file looks like this, now:

[root@server30 ~]# cat /etc/e-smith/templates-user-custom/.qmail/80Zarafa
{
   my $zarafa = $user->prop('zarafa') || 'disabled';
   my $zarafa2 = ${'zarafa-server'}{GlobalForward} || 'disabled';

    if ($zarafa eq 'enabled' || $zarafa2 eq 'enabled') {
    if ( $USERNAME ne 'info' ) {
return "| /usr/bin/zarafa-dagent -q $USERNAME ; if [ $? -ne 0 ] ; then exit -1; else exit 99; fi;";
}
else
{
return "| /usr/bin/zarafa-dagent --public 'Public Folders\\Info' -C info ; if [ $? -ne 0 ] ; then exit -1; else exit 99; fi;";
}
}

So there is a syntax that is not exact someplace, sorry to drag you through this, your help is very much appreciated.

Many thanks


Gund


Offline gundar

  • *
  • 25
  • +0/-0
Re: Custom .qmail Template Required for Single User - How?
« Reply #7 on: July 23, 2009, 12:58:16 AM »
Oh, wait, there are too many '{'s' on the field...

Testing.

REboot.

Reconfigure...


Works!

Solution in a minute, just responding to fire alarm...

Offline gundar

  • *
  • 25
  • +0/-0
Re: Custom .qmail Template Required for Single User - How?
« Reply #8 on: July 23, 2009, 01:29:32 AM »
Alright, the building survived!

So, the solution, to get Zarafa to deliver email to a public folder is as such:

Installed SMEServer 7.3, updated to 7.4 using usual step.

Installed Zarafa for 'db' option as per the contribs instructions on this site.

Created three users in SMEServer server-manager page (one of which has username 'info').

Disabled webmail in Email panel (not required, but a step I took).

Created three users in Zarafa using Zarafa panel (it only appeared after the second reboot of server)...

In Outlook, using the Zarafa client, I created a public folder called Info and gave all three users full permissions to folder using one of the Zarafa users I had delegated as administrative fromt eh Zarafa panel in server-manager page).

At the console of the SMEServer, as root, created this file (with the great, professional help I had on this post):

[root@server30 ~]# cat /etc/e-smith/templates-user-custom/.qmail/80Zarafa
{
   my $zarafa = $user->prop('zarafa') || 'disabled';
   my $zarafa2 = ${'zarafa-server'}{GlobalForward} || 'disabled';

    if ($zarafa eq 'enabled' || $zarafa2 eq 'enabled') {
    if ( $USERNAME ne 'info' ) {
return "| /usr/bin/zarafa-dagent -q $USERNAME ; if [ $? -ne 0 ] ; then exit -1; else exit 99; fi;";
}
else
{
return "| /usr/bin/zarafa-dagent --public 'Public Folders\\Info' -C info ; if [ $? -ne 0 ] ; then exit -1; else exit 99; fi;";
}
}
}


Notice it ends with three }'s one on each line, copy and paste carefully.

signal-event email-update

Will alter the .qmail folders in each users home and make teh 'info' user different as such (comapring 'gund' and 'info'):

[root@server30 ~]# cat /home/e-smith/files/users/gund/.qmail
#------------------------------------------------------------
#              !!DO NOT MODIFY THIS FILE!!
#
# Manual changes will be lost when this file is regenerated.
#
# Please read the developer's guide, which is available
# at http://www.contribs.org/development/
#
# Copyright (C) 1999-2006 Mitel Networks Corporation
#------------------------------------------------------------


| condredirect gund-junkmail headermatch 'X-Spam-Status: Yes'
# Forward not set
| /usr/bin/zarafa-dagent -q gund ; if [ 0 -ne 0 ] ; then exit -1; else exit 99; fi;
./Maildir/



[root@server30 ~]# cat /home/e-smith/files/users/info/.qmail
#------------------------------------------------------------
#              !!DO NOT MODIFY THIS FILE!!
#
# Manual changes will be lost when this file is regenerated.
#
# Please read the developer's guide, which is available
# at http://www.contribs.org/development/
#
# Copyright (C) 1999-2006 Mitel Networks Corporation
#------------------------------------------------------------


| condredirect info-junkmail headermatch 'X-Spam-Status: Yes'
# Forward not set
| /usr/bin/zarafa-dagent --public 'Public Folders\Info' -C info ; if [ 0 -ne 0 ] ; then exit -1; else exit 99; fi;
./Maildir/



Note, if you don't use SME, and you use qmail in most other Linux distro's, this second file, from 'info' user is what your .qmail should look like, substitute folder names etc as required. Essentially, this tells qmail application to respond with this command if email is pushed out to 'info' user.

Now, when email is sent to info@yourdomains.com is automatically gets delivered to the Info public folder, so that any employee can see the email and react to the customer's query.

Note, I used 6.20-7 and there is a bug listed where you cannot reply to this email while it is in the public folder. This has been address in 6.20-8, which I have yet to try, refer to zarafa forums for more info.

I hope this helps anybody who want to use Zarafa with SME, so far, we are happy with the product, it has a high WAF (wife acceptance factor), too.

Cheers, thanks for the script help here, I can use this information elsewhere.


Gund
« Last Edit: July 23, 2009, 01:34:11 AM by gundar »

Offline stephen noble

  • *
  • 607
  • +1/-0
    • Dungog
Re: Custom .qmail Template Required for Single User - How?
« Reply #9 on: July 27, 2009, 01:12:03 PM »
good work
added to smeserver-zarafa
http://bugs.contribs.org/show_bug.cgi?id=5412

Offline Stefano

  • *
  • 10,894
  • +3/-0

Offline gundar

  • *
  • 25
  • +0/-0
Re: Custom .qmail Template Required for Single User - How?
« Reply #11 on: July 27, 2009, 07:36:15 PM »
Hi

Updated 6.20-7 to 6.30 and can reply to email on the Info folder, so this all works sweetly, as expected now.

Cheers and many thanks for the help.

Rgds


Gund