You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lenya.apache.org by Richard Frovarp <Ri...@sendit.nodak.edu> on 2006/12/11 20:53:40 UTC

[1.4] Mail Notification

I am obviously missing something. How does one go about getting email 
notifications to work? I see the note about removing the geronimo-.jars 
and getting activation.jar and mail.jar from Sun.  Before and after 
doing that, I don't see anything going to my local sendmail. I don't see 
anything going out either by watching with tcpdump. What more needs to 
be done?

Thanks,
Richard

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: [1.4] Mail Notification

Posted by Andreas Hartmann <an...@apache.org>.
Hi Richard,

Richard Frovarp schrieb:
> I am obviously missing something. How does one go about getting email
> notifications to work? I see the note about removing the geronimo-.jars
> and getting activation.jar and mail.jar from Sun.  Before and after
> doing that, I don't see anything going to my local sendmail. I don't see
> anything going out either by watching with tcpdump. What more needs to
> be done?

I just tested the notification again and noticed that some functionality
was missing. After fixing some issues, it works for me now.
I updated the documentation, but since I'm too lazy to update the
website ATM I'm attaching it here.

HTH,

-- Andreas

--------------------------------------------------------------------

Notification
============

Setup
-----

    * To enable notification by e-mail, you have to download the
JavaMail and JavaBeans Activation Framework libraries from the JavaMail
website and place them in the <lenya-webapp>/WEB-INF/lib directory.

    * Edit cocoon.xconf, look for the component with the class
org.apache.lenya.notification.EmailNotifier and update the attributes of
the <smtp> element with the settings of your SMTP host. The user and
password attributes are optional.

      <component logger="lenya.notification"
          role="org.apache.lenya.notification.Notifier"
          class="org.apache.lenya.notification.EmailNotifier">
        <smtp host="localhost" username="john" password="swordfish" />
      </component>

    * If you test the functionality with the default users lenya and
alice, don't forget to configure their e-mail addresses.

    * To check if the notification works, go to your Inbox and send a
message.


How to Send Notification Messages
---------------------------------

There are two ways to send notification messages - either immediately,
or by attaching a notification event to the current session. In the
latter case, the notification is sent only if the transaction has been
successfully completed.

To send notification messages, use the Notifier component which is
provided by the notification module. A shortcut to the Notifier
functionality is offered by the NotificationUtil utility class. Here's
an example how to send a notification message immediately:

protected void notify(User sender, User recipient, document) {

    Identifiable[] recipients = { recipient };

    // compose message, using parameters for i18n

    String subject = "publish-notification";
    String[] subjectParams = {};

    String body = "document-was-published"
    String[] bodyParams = { document.getId() };
    Message message = new Message(subject, subjectParams, body,
bodyParams, sender, recipients);

    // send message

    NotificationUtil.notify(this.manager, message);
}

The following example shows how to attach a notification event to the
session, for instance inside a usecase handler:

    NotificationEventDescriptor descriptor = new
NotificationEventDescriptor(message);
    RepositoryEvent event = RepositoryEventFactory
        .createEvent(this.manager, authoringDocument, getLogger(),
descriptor);
    getSession().enqueueEvent(event);

The message is sent to each particular recipient, translated using the
recipient's locale.

The default implementation, EmailNotifier, sends an email to each
recipient and adds the message to their inboxes. Future implementations
could include a message list which is managed by the CMS and is
presented to a user after she logs in.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org