App enabled/disable activity

Hello everyone,
i want to develop an App that will send Email to every admin when an App is enabled or disabled. please can someone help me with a function that can send email to admin?

I have tried with some given functions but it doesn’t work. Something should be lacking.

thank you

1 Like

Maybe server/AppManagement.php at master · nextcloud/server · GitHub can serve you as an example?
It logs the same actions into the admin audit log

1 Like

Makes me think of the announcement center app.
Seems it does not yet support notification by email

1 Like

Yes it serves me as an example. In AppManagement.php in the place of log function i instead called the mail function to send email but it doesn’t still work. please check it in the link.

Maybe you add some logging or write a file on disk to check if the email is the problem or your app is not loaded/invoked
Hard to judge without seeing the full app code/repo

1 Like

Thank you @nickvergessen this is the app code/repo

i’m very new in App developement, so something maybe lacking in the code that i may not be aware of. i please need your idees.

Most likely you miss this part from your app’s info.xml
After adding it you need to increase the version number as the changes are only updated inside nextcloud when an app is updated.

1 Like

i have added the missing part in the info.xml and i updated the App version as you said. But it still doesn’t work. May be the events have not been logged or something else.

Hello @nickvergessen please how can i check whether my App receives the info from the log file?

or before i send out the email, how should i first do a secure debug?

Hello everyone,
i would like administrators to get email when a particular event occurs. But when i use this program example => , it doesn’t work when it is called.

Can someone please help me with a SendEmailToAdmin code function?

i will greatly appreciate