phpgroupware-developers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [AngleMail] Re: [Phpgroupware-developers] plans for a notification m


From:
Subject: Re: [AngleMail] Re: [Phpgroupware-developers] plans for a notification mechanism in the API?
Date: Fri, 22 Nov 2002 22:55:54 +0000

The short reply:

a) the issue of an email "server" actually notifying the email "client" when new
mail arrives in the INBOX is something that MS MAPI does and also I think the 
Cyrus
IMAP server has an unofficial API for that.

As for anglemail, it provides easy to access information about folder status, in
particular the INBOX, this is very easy, really 4 lines of code gives you the 
whole
thing:

> // make the "msg" object, "bootstrap" is smart, only creates it once
> // and use its generic login function, takes care of details for you
>1) $my_msg_bootstrap = '';
>2) $my_msg_bootstrap = CreateObject("email.msg_bootstrap");
>3) $my_msg_bootstrap->login();

> // not use "msg" object to get mailbox status
> // no params means INBOX for email default account 0
>4) $inbox_data = $GLOBALS['phpgw']->msg->new_message_check();

* you will get an array, the general stuff is this:
> $inbox_data['is_imap'] boolean
> $inbox_data['folder_checked'] string
> $inbox_data['alert_string'] string
> $inbox_data['number_new'] integer
> $inbox_data['number_all'] integer

* a brief explanation
> "is_imap", pop3 does not know what is "new" or not, imap does
> "folder_checked", the folder we just checked
> "alert_string", a fully lang'd string to show the user
> > example: "You have no new messages"
> "number_new", for IMAP is number "unread", for pop3 is total messages
> "number_all", for IMAP and pop3 is total number messages in that inbox

So you can call that as often as you like, the "bootstrap" stuff is "safe and
smart", you can put it a lot of places in your code, but the "bootstrap" stuff 
will
never create more then one "msg" object, and it will give it basic default 
values
for you. If you care to learn more, it can do more, but it provides this
simple "public" interface so it is easy to use.

As for the this command:
> $inbox_data = $GLOBALS['phpgw']->msg->new_message_check();

That is kind of a "public" function, it takes care of providing basic default
values for you, it does all kinds of extra validation and stuff on the params, 
or
lack of params, you give it, because it is meant to be an easy to use "public" 
type
of function. Again, it you want to learn more, it could check any folder of any
account, but it is also designed to be simple, even requiring no params, so the
learning curve is low.

Then you get back an array that already includes a
fully lang'd string ready to show the user. You can use that 
"->new_message_check
()" to check the INBOX as often as you like, but I recommend checking every 4
minutes as the most minimum loop time, less than that is probably too often.

b) as for making public functions so people can send more than just a simple
message, such as for sending multi part mime mails like mail with 
attachment(s), or
mail with "parts" that might include XML-RPC data, stuff like that ... yes I
already have this "public" interface planned out in my mind, I just need to sit
down and actually make the code.

As you can see above, the 1st 3 lines of code just make sure we have a "msg"
object. After that I'll probably have different ways to make and sent mail, 
ranging
from "no-brainer" public functions, to extremely versatile stuff for advanced 
usage.

Dave Hall (address@hidden) wrote*:
>
>address@hidden wrote:
>
>> Hello,
>>
>> I want to add to a custom app we have developped a simple
>> mechanism of
>> sending an email to one adress (a mailing list) when a new information
>> item is added. I have looked in the list archives and on the IRC logs
>> and found that the issue of notification per email comes up regularly
>> and that there is some support for it in the calendar app. And I
>> remember one post I cannot find again, where somebody told about
>> setting up something like a generic notification mechanism.
>
>Stephen Cremer aka scr was working on this iirc.  He was wroking on
>sending iCal attachments.  I don't know the status of the project.
>Maybe he will respond here.
>
>Another place to get some info on the mail stuff may be the anglemail
>list "anglemail at free-source dot com".  I have emailed this message
>there.  If you need/want to hack it yourself this would be the place to
>ask questions about email.  afaik there are no public archives of this
>list so you either need to subscribe or ask that people cc you.
>
>
>>
>> Is there any plan for developping such a mechanism in the API, that
>> would provide an app with simple functions to send any kind of email
>> to any kind of adress? If not, is there any interest of users to see
>> something like that happen? Do you have any special ideas of the
>> requirements for such a mechanism, should it be hook_based?
>>
>> What would be most useful for me at the moment, were just an API
>> object, which could be initialized with an array of adresses, or
>> alternatively a list of user-IDs and either construct adresses based
>> on address@hidden or fetch them from LDAP, and some sort of
>> specification for content (ideally permitting multiple part MIME
>> emails) and that take care of sending the mails out.
>>
>> My excuses if I missed something that is already obvious in the docs.
>
>Attachments are not supported by the api email function at the moment.
>I am not sure if the api supports obtaining the user's email address.
>There are some issues with this, there are 2 email apps, anglemail
>supports multiple accounts, this is also planned for felamimail.
>
>
>The dev doc is a bit old, but this is what i found:
>
>5.5  Email/NNTP Functions
>
>$phpgw->send->msg
>
>$phpgw->msg->send($service, $to, $subject, $body, $msgtype, $cc, $bcc)
>Send a message via email or NNTP and returns any error codes.
>Example:
>
>$to = "address@hidden";
>$subject = "Hello buddy";
>$body = "Give me a call\n Been wondering what your up to.";
>$errors = $phpgw->msg->send("email", $to, $subject, $body);
>
>Note: replace $phpgw with $GLOBALS['phpgw']
>
>

--
That's "angle" as in geometry.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]