Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Zimlet to Pre-Process Email

Hybrid View

  1. #1
    Join Date
    Mar 2008
    Posts
    15
    Rep Power
    7

    Default Zimlet to Pre-Process Email

    I would like to create a Zimlet that does some processing on an email before it is sent. Basically, when the user clicks the Send button, the Zimlet would need to do some action on the email text before the standard "Send" action is completed. I've made quite a few Zimlets now, so I'm no longer a rookie, but this has me stumped.

    A lot of command-driven frameworks I've worked with allow you to add listeners to events. For example, you could subscribe to the "onSend" command and implement a doBeforeSend method. Can I do anything like this with Zimbra?

  2. #2
    Join Date
    Mar 2008
    Posts
    40
    Rep Power
    7

    Default

    Did you find the way to do that? I need to do exactly the same thing. Anyone have some ideas ?

  3. #3
    Join Date
    Mar 2008
    Posts
    15
    Rep Power
    7

    Default

    Yes, I did, but there was no elegant way to do it. I had to go in and edit the Zimbra source a little, which means that it breaks on every update. I have to go in an redo this by hand after each update.

    Basically I wrote a JS class called MailProcessor as part of a Zimlet. Then near the end of at the end of ZmMailMsg.prototype.send in MailCore_all.js, add:

    Code:
     var arp = new MailProcessor();
     arp.processEmail(params);
    Then from the command prompt:

    cp MailCore_all.js MailCore_all.js.
    gzip -S zgz MailCore_all.js.

    Do this at your own risk and not on a production server. The odds of breaking something along the way are high.

  4. #4
    Join Date
    Mar 2008
    Posts
    40
    Rep Power
    7

    Default

    Yes, i was thinking about that. But I really didn't want to change anything in Zimbra source. So I found another solution, maybe not the best but it works for me.
    I replaced the selection listener in a button 'Send' with my own so i could launch my function sendMsg() which is almost the same as a ZmComposeController.SendMsg - just before message is send I do some operations on it.

  5. #5
    Join Date
    Sep 2005
    Posts
    187
    Rep Power
    10

    Default

    In Zimbra 6.x I have added a hook to support pre-processing and we will have to wait for that to be released.
    Bugzilla - Wiki - Downloads - Before posting... Search!

  6. #6
    Join Date
    Mar 2008
    Posts
    15
    Rep Power
    7

    Default

    Thanks! When the time comes, will you give us an example of how to use it?

  7. #7
    Join Date
    Sep 2005
    Posts
    187
    Rep Power
    10

    Default

    The function to override is emailErrorCheck. It is automatically called by Zimbra just before email is sent(after Send button is clicked). And waits to see if the function returns
    "null" - in case of no-issues or
    "{hasError:true, errorMsg:"your email has so and so issue", zimletName:"com_zimbra_checkEmail"}" - in case of any issue.

    If there is any issue, Zimbra then shows a dialog:
    "your email has so and so issue", do you wish to continue?
    [Yes] [No]


    Code:
    com_zimbra_checkEmail.prototype.emailErrorCheck =
    function(mail, boolAndErrorMsgArray) {
      
       var bodyText = mail.getBodyContents();
      <check email for errors or something>
    
      if(hasError) {
    	return boolAndErrorMsgArray.push({hasError:true, errorMsg:"your email has so and so issue", zimletName:"com_zimbra_checkEmail"});
      } else {
        return null;//no errors 
      }
    }
    I am in the process of documenting all these things @ wiki.zimbra.com
    Bugzilla - Wiki - Downloads - Before posting... Search!

  8. #8
    Join Date
    Oct 2007
    Location
    North East England
    Posts
    167
    Rep Power
    8

    Default

    Will there be functionality available that will prevent the message from being sent until a certain condition has been met? I can see this being a great way to develop a more efficient content filter for school use, which will prevent students from sending out messages containing swear words.

    Eg. instead of "Do you wish to continue - Yes/No" - could the Zimlet say, for example, "Cannot continue due to Error X - OK".
    Last edited by webman; 04-02-2009 at 02:54 AM.
    Craig Rodway &#187; Flickr | Last.fm | Del.icio.us | Twitter

  9. #9
    Join Date
    Jul 2009
    Posts
    2
    Rep Power
    6

    Default Changing the message content

    Hi,

    In the pre-processing operations, is it possible to change the content of message, e.g., text and attachment? If you have any clue, please help.

  10. #10
    Join Date
    Nov 2011
    Posts
    1
    Rep Power
    4

    Default

    Hi,

    Could you explain agnes how do you succed in changing text containt before make a new request ?

    Thx,

Similar Threads

  1. Replies: 21
    Last Post: 02-04-2010, 10:06 AM
  2. Can't seem to get global in BES
    By sdemeyer in forum Zimbra Connector for BlackBerry
    Replies: 12
    Last Post: 03-19-2008, 09:22 AM
  3. need advice on configuring zimbra to work with fax server
    By pheonix1t in forum Administrators
    Replies: 0
    Last Post: 07-11-2007, 08:46 PM
  4. upgrade to 4.0.3 antispam does'nt work
    By lucanannipieri in forum Administrators
    Replies: 14
    Last Post: 11-07-2006, 03:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •