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

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 04-16-2008, 06:45 AM
Intermediate Member
 
Posts: 15
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?
Reply With Quote
  #2 (permalink)  
Old 07-21-2008, 02:24 AM
Active Member
 
Posts: 40
Default

Did you find the way to do that? I need to do exactly the same thing. Anyone have some ideas ?
Reply With Quote
  #3 (permalink)  
Old 07-21-2008, 07:44 AM
Intermediate Member
 
Posts: 15
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.
Reply With Quote
  #4 (permalink)  
Old 07-23-2008, 07:13 AM
Active Member
 
Posts: 40
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.
Reply With Quote
  #5 (permalink)  
Old 03-31-2009, 12:43 PM
Zimbra Employee
 
Posts: 187
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!
Reply With Quote
  #6 (permalink)  
Old 03-31-2009, 12:51 PM
Intermediate Member
 
Posts: 15
Default

Thanks! When the time comes, will you give us an example of how to use it?
Reply With Quote
  #7 (permalink)  
Old 03-31-2009, 01:51 PM
Zimbra Employee
 
Posts: 187
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!
Reply With Quote
  #8 (permalink)  
Old 04-02-2009, 01:50 AM
Special Member
 
Posts: 167
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".
__________________
Craig Rodway » Flickr | Last.fm | Del.icio.us | Twitter

Last edited by webman; 04-02-2009 at 01:54 AM..
Reply With Quote
  #9 (permalink)  
Old 08-12-2009, 04:34 AM
Starter Member
 
Posts: 2
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.
Reply With Quote
  #10 (permalink)  
Old 11-08-2011, 03:51 AM
Starter Member
 
Posts: 1
Default

Hi,

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

Thx,
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.