E-Mail flag for users: Difference between revisions

From MoodleDocs
(Created page with "Changing the email flag of a user prevents/allows him from receiving emails from Moodle. Moodle contains a CLI script to change the email flag for one or many users at a time....")
 
m (Added link to Spanish page)
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
Changing the email flag of a user prevents/allows him from receiving emails from Moodle. Moodle contains a CLI script to change the email flag for one or many users at a time. Also the current state whether the email flag is off or on can be displayed. A possible use case for this script is to automate process of scanning the log file of the mail server (e.g. postfix) and extract email addresses that are reported there. If an email is invalid/rejected for mail delivery, this address can be taken as an argument for the cli script and the email flag can be sent to disable sending emails by Moodle for that particular address.
Changing the email flag of a user prevents/allows him from receiving emails from Moodle. Moodle contains a CLI script to change the email flag for one or many users at a time. Also, the current state whether the email flag is off or on can be displayed. A possible use case for this script is to automate process of scanning the log file of the mail transfer agent (e.g. postfix) and extract email addresses that are reported there. If an email is invalid/rejected for mail delivery, this address can be taken as an argument for the cli script to change the emailstop flag so that the user does not receive any further emails.
 
The CLI script <code>emailstop.php</code> is located in the <code>admin/cli</code> of the Moodle installation.
The CLI script <code>emailstop.php</code> is located in the <code>admin/cli</code> of the Moodle installation.


Accepted command line arguments are:
Accepted command line arguments are:


* <code>-h</code>, <code>--help</code> Print out a help screen that mentions all possible agruments that can be set.
    -h, --help             Print out a help screen that mentions all possible agruments that can be set.
* <code>-e</code>, <code>--email=email</code> Specify an user by email, separate many users by comma.
    -e, --email=email       Specify an user by email, separate many users by comma.
* <code>-i</code>, <code>--id=id</code> Specify an user by the internal database id, separate many ids by comma.
    -i, --id=id             Specify an user by the internal database id, separate many ids by comma.
* <code>-q</code>, <code>--quiet</code> Do not print anything out to stdout. The success of the script can still be controlled by the exit code.
    -q, --quiet             Do not print anything out to stdout. The success of the script can still be controlled by the exit code.
* <code>-s</code>, <code>--stop=0|1|off|on</code> Set a new value for emailstop flag
    -s, --stop=0|1|off|on   Set a new value for emailstop flag
* <code>-u</code>, <code>--username=username</code> Specify user by username, separate many users by comma.
    -u, --username=username Specify user by username, separate many users by comma.


To identify one or many users, only one of the options <code>-e</code>, <code>-i</code>, or <code>-u</code> can be used. For convenient reasons many users can be set at once, and must be separated by a comma e.g. <code>php admin/cli/emailstop.php -u=student1,student2,student3</code>.
To identify one or many users, only one of the options <code>-e</code>, <code>-i</code>, or <code>-u</code> can be used. For convenient reasons many users can be set at once, and must be separated by a comma e.g. <code>php admin/cli/emailstop.php -u=student1,student2,student3</code>.
Line 18: Line 18:
Sample calls:
Sample calls:


* <code>php admin/cli/emailstop.php --email=student1@example.org --stop=1 -q</code> Disable receiving email for the user with email ''student1@example.org''. No output is generated.
    $ php admin/cli/emailstop.php --email=student1@example.org --stop=1 -q
* <code>php admin/cli/emailstop.php --email=student1@example.org</code> Show the status of the email stop flag for the user with email ''student1@example.org''.
 
Disable receiving email for the user with email ''student1@example.org''. No output is generated.
 
    $ php admin/cli/emailstop.php --email=student1@example.org
 
Show the status of the email stop flag for the user with email ''student1@example.org''.
 
[[es:Señalización de E-mail para usuarios]]

Latest revision as of 14:17, 24 August 2023

Changing the email flag of a user prevents/allows him from receiving emails from Moodle. Moodle contains a CLI script to change the email flag for one or many users at a time. Also, the current state whether the email flag is off or on can be displayed. A possible use case for this script is to automate process of scanning the log file of the mail transfer agent (e.g. postfix) and extract email addresses that are reported there. If an email is invalid/rejected for mail delivery, this address can be taken as an argument for the cli script to change the emailstop flag so that the user does not receive any further emails.

The CLI script emailstop.php is located in the admin/cli of the Moodle installation.

Accepted command line arguments are:

   -h, --help              Print out a help screen that mentions all possible agruments that can be set.
   -e, --email=email       Specify an user by email, separate many users by comma.
   -i, --id=id             Specify an user by the internal database id, separate many ids by comma.
   -q, --quiet             Do not print anything out to stdout. The success of the script can still be controlled by the exit code.
   -s, --stop=0|1|off|on   Set a new value for emailstop flag
   -u, --username=username Specify user by username, separate many users by comma.

To identify one or many users, only one of the options -e, -i, or -u can be used. For convenient reasons many users can be set at once, and must be separated by a comma e.g. php admin/cli/emailstop.php -u=student1,student2,student3.

The -q param prevents any output on stdout. Using -q qithout the -s argument doesn't make much sense then.

Sample calls:

   $ php admin/cli/emailstop.php --email=student1@example.org --stop=1 -q

Disable receiving email for the user with email student1@example.org. No output is generated.

   $ php admin/cli/emailstop.php --email=student1@example.org

Show the status of the email stop flag for the user with email student1@example.org.