Test email templates

  • Hi,

    I'm adding a new kind of notification that I call from another web site using Woltlab API. I'm working on the mail template but would like to test it instantly.
    Data to test is from my implementation of AbstractUserNotificationEvent::getEmailMessage().

    How can I see a direct result in PHP console of this mail template?
    How can I force sending mail instantly? This notification is already set to "instant" for this user, but actually, sometimes I receive the mail instantly, and sometimes I don't receive it, I try to log out, log in, refresh pages from another user, I never know what triggers the sending of the mail and this is almost impossible to work.

    I also tried to set notification as daily mail et run cronjob "Sends daily mail notifications" from admin, but that doesn't send email.

    Note: email configuration is good, if I use admin "Email Users" feature, mail is received instantly.

    Thank you.

    Edited 3 times, last by RFRO (December 2, 2023 at 12:48 PM).

  • Hello,

    There is a built-in test tool for notifications that relies on wcf\system\user\notification\event\ITestableUserNotificationEvent being implemented, alongside with TTestablePostUserNotificationEvent from the same namespace that eases the process.

    The test feature is enabled when both the debug mode and the developer tools are enabled. Enabling both will also turn mail sending into a synchronous/blocking mode instead of relying on the background queue for an asynchronous processing.

  • I think I'm almost done but have an issue on notification title and I don't know from where it comes.

    It looks like it affects only instant notification, mail title is: New Notification: {@$title}

    I'm overriding both methods getMailTitle() and getTitle() (first one is useless I presume):

    What am I missing? :/

  • Hello,

    I cleared cache and next notification was fine. :thumbup:

    Where was this cache stored? I'm a bit surprised because I reinstalled Woltlab from scratch, deleted old files and database, so I'm surprised a cache has persisted. Maybe it was in my XAMPP tmp directory?

  • OK.

    I have a (probably last) question about notification and mail: sometimes I don't have an author for the notification, I tried to pass "null" for the user ID and it looks like there's no problem with that, can you confirm it's supported? If not, I can create a default user for those notifications.

    This is where I pass null, in parameter $woltlabAuthorId :

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!