Description of issue or problem I’m having:
I have a plugin that enables the user to fill in a form on the frontend, the contents of which are to be emailed to the OJS site admin/editor email address. The form is complete and the form data is being posted but I don’t know how to get OJS to email this information in the background to the site admin/editor.
I have been looking for examples of how to do this but have not been able to find anything.
Where would be the best place to start looking for an example of this email sending mechanism?
Steps I took leading up to the issue:
The plugin is created and working, but the final step of being able to email the form contents eludes me.
What I tried to resolve the issue:
I have been looking for code examples on the forums and also searching through the codebase but can’t find any succinct examples.
Application Version - e.g., OJS 3.1.2:
I appreciate any help I can get here,
Many thanks in advance.
Quick update - I have found the site admin email value, so no problems there. Just still interested in seeing how to send a quick email via code to the admin.
Take a look at the: pkp-lib/Mail.inc.php at stable-3_3_0 · pkp/pkp-lib · GitHub
Something like this should work:
$email = new Mail();
$email->setBody('The content of the email');
$email->setSubject('The subject of the email');
An example: pkp-lib/PKPEmailHandler.inc.php at stable-3_3_0 · pkp/pkp-lib · GitHub.
If you are working with the form that extends OJS
Form class, you can add the email sending code in the
execute() method. Or, as per the linked example, put it on queue to run in the background.
Hi @Vitaliy - thanks for that, it works OK for me so I’m happy. The oauth2 google stuff didn’t work (I can’t see how it even would) but as long as one of the methods works that’s good enough.
This topic was automatically closed after 2 days. New replies are no longer allowed.