[BUG]: Not able to send email from front-end action #1225

Open
opened 2025-06-13 17:19:07 +00:00 by cpaschen · 1 comment

What Happened?

[This may not be a bug, possible a feature limitation of emails, or how to properly implement emails when sending from front-end, as sending from admin side is working properly.]

I have a front-end custom coded module, that calls functions within the site helper class.
All of the other function calls work fine; however, trying to call the emailHelper results in a 'class not found' error.

Steps to reproduce the Bug

  1. Create site module that has a button that
    a. calls a function from the helper module
    The module main php file loads the component helper file directly via:
    JLoader::register('KrbooksHelper', JPATH_BASE . '/components/com_krbooks/helpers/krbooks.php');
    b. that function calls another function (sendSysEmails)
    c. that function includes a call to send email [ $userMessageSent = KrbooksEmail::send(...) ]
  2. When the button is clicked, all of the actions within the first function (a) happen properly; and all the steps in the second function (b) happen properly up until the line where the the email helper class function is called.

The error returned is:

0 Class "KrbooksEmail" not found
Call stack

Function Location

1 () JROOT/administrator/components/com_krbooks/helpers/krbooks.php:3117
2 KrbooksHelper::sendSysEmail() JROOT/administrator/components/com_krbooks/helpers/krbooks.php:17071
3 KrbooksHelper::reviewAcceptReject() JROOT/modules/mod_krbooks_dashboard_reviewerassignments/tmpl/default.php:59
4 require() JROOT/modules/mod_krbooks_dashboard_reviewerassignments/mod_krbooks_dashboard_reviewerassignments.php:39

Which Joomla version are you compiling in?

3.10.12

Which PHP version are you compiling in?

8.0.30

Which Joomla versions are you targeting?

3.10.12

Which PHP version are you targeting?

8.0.30

Which Web server is JCB running on?

Apache/2.4.56

Which Relational Database is JCB running on?

mysql / MariaDB 11.7.2

Which OS is JCB running on?

Debian via Octojoom; joomla official docker image

Which JCB version are you using?

3.2.4

Where in JCB did this issue occur?

Other

On which browsers did you encounter the issue?

Firefox

Additional Comments

I'm not sure ....

  1. If the email sending feature through JCB is able to be called from the front-end/site as there isn't a copy of the emailHelper file in the site/helper folder (like it is in the admin helper folder)

  2. Why, if I am specifically calling the site component helper file (from my custom module - which was NOT generated by JCB), the call stack indicates that the functions being called are from the admin helper file

As noted above, sending from any 'place' within the admin code works fine when calling the email::send function, it just fails when trying to call it from the site/front-end.
So I'm wondering if this is a limitation, or exactly what needs to be done to make it to work from the site/front-end.

BTW ... I've already tried to manually load the email helper within the sendSysEmail function (that calls the email helper::send function), both in the site component helper and the admin component helper. I've also tried manually loading the email helper from within my custom module's main PHP file, but nothing seems to work to help it 'see' the helper class.

Any tips would we welcome.

Also, if this is something that has been resolved in the later JCB versions for 4/5 please let me know and I'll just disable the email functionality from the site end until we can upgrade this project.

### What Happened? [This may not be a bug, possible a feature limitation of emails, or how to properly implement emails when sending from front-end, as sending from admin side is working properly.] I have a front-end custom coded module, that calls functions within the site helper class. All of the other function calls work fine; however, trying to call the emailHelper results in a 'class not found' error. ### Steps to reproduce the Bug 1. Create site module that has a button that a. calls a function from the helper module The module main php file loads the component helper file directly via: JLoader::register('KrbooksHelper', JPATH_BASE . '/components/com_krbooks/helpers/krbooks.php'); b. that function calls another function (sendSysEmails) c. that function includes a call to send email [ $userMessageSent = KrbooksEmail::send(...) ] 2. When the button is clicked, all of the actions within the first function (a) happen properly; and all the steps in the second function (b) happen properly up until the line where the the email helper class function is called. The error returned is: 0 Class "KrbooksEmail" not found Call stack # Function Location 1 () JROOT/administrator/components/com_krbooks/helpers/krbooks.php:3117 2 KrbooksHelper::sendSysEmail() JROOT/administrator/components/com_krbooks/helpers/krbooks.php:17071 3 KrbooksHelper::reviewAcceptReject() JROOT/modules/mod_krbooks_dashboard_reviewerassignments/tmpl/default.php:59 4 require() JROOT/modules/mod_krbooks_dashboard_reviewerassignments/mod_krbooks_dashboard_reviewerassignments.php:39 ### Which Joomla version are you compiling in? 3.10.12 ### Which PHP version are you compiling in? 8.0.30 ### Which Joomla versions are you targeting? 3.10.12 ### Which PHP version are you targeting? 8.0.30 ### Which Web server is JCB running on? Apache/2.4.56 ### Which Relational Database is JCB running on? mysql / MariaDB 11.7.2 ### Which OS is JCB running on? Debian via Octojoom; joomla official docker image ### Which JCB version are you using? 3.2.4 ### Where in JCB did this issue occur? Other ### On which browsers did you encounter the issue? Firefox ### Additional Comments I'm not sure .... 1. If the email sending feature through JCB is able to be called from the front-end/site as there isn't a copy of the emailHelper file in the site/helper folder (like it is in the admin helper folder) 2. Why, if I am specifically calling the site component helper file (from my custom module - which was NOT generated by JCB), the call stack indicates that the functions being called are from the admin helper file As noted above, sending from any 'place' within the admin code works fine when calling the email::send function, it just fails when trying to call it from the site/front-end. So I'm wondering if this is a limitation, or exactly what needs to be done to make it to work from the site/front-end. BTW ... I've already tried to manually load the email helper within the sendSysEmail function (that calls the email helper::send function), both in the site component helper and the admin component helper. I've also tried manually loading the email helper from within my custom module's main PHP file, but nothing seems to work to help it 'see' the helper class. Any tips would we welcome. Also, if this is something that has been resolved in the later JCB versions for 4/5 please let me know and I'll just disable the email functionality from the site end until we can upgrade this project.
cpaschen added the
Bug
label 2025-06-13 17:19:07 +00:00
Owner

To call the email class please use:

Joomla___025399e0_cab7_4cc8_8f91_62e077039acd___Power::send(...);

This will ensure the correct class is called. We have also spend some time refactoring the EmailHelper class, so check out v5.1.1 as it holds all the latest updates to this area.

To call the email class please use: ``` Joomla___025399e0_cab7_4cc8_8f91_62e077039acd___Power::send(...); ``` This will ensure the correct class is called. We have also spend some time refactoring the EmailHelper class, so check out v5.1.1 as it holds all the latest updates to this area.
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: joomla/Component-Builder#1225
No description provided.