Hi Camille,
for a full (and very simple) example that expands on Davo's answer, you can have a look at my "Notify site administrators about new Email Signups" plugin (https://moodle.org/plugins/local_notifyemailsignup). You can browse the code at https://github.com/iarenaza/moodle-local-notifyemailsignup
Saludos. Iñaki.