====== How to set up phpList command-line interface (CLI) ====== To be able to run phpList from commandline you need to use the **CLI version of PHP**. To verify your version, type php -v This should return something similar to the following: PHP 7.1.9 (cli) (built: Sep 6 2017 11:45:26) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.1.9, Copyright (c) 1999-2017, by Zend Technologies with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans The (cli) on the first line indicates the **CLI version of PHP**. It should not say "cgi" or something else. If you do not get CLI, [[https://www.google.com.ar/search?q=how+to+install+php-cli|find out how to install it]] before continuing. ===== install phpList on commandline ===== Use your favourite command-line text editor to edit (or create if it doesn't exist) a file called /usr/local/bin/phplist With the following content, replacing the paths with what is appropriate for your environment: #!/bin/bash /usr/bin/php /path/to/your/phplist/lists/admin/index.php -c /path/to/your/phplist/lists/config/config.php $* Make it executable: chmod 755 /usr/local/bin/phplist The crucial element is the **"-c config.php"** which tells phpList where your config file is. From then on, you will be able to execute phpList from the command-line. ===== Executing sub-commands ===== To execute a sub-command run the phpList binary with the -p flag followed by the sub-command name without a space. E.g.: ./bin/phplist -pprocessqueue ===== Available sub-commands ===== Running the phpList command-line script with no arguments will result in a printed list of available sub-commands. The list should look like this: dbcheck send processqueue processbounces import upgrade convertstats reindex blacklistemail systemstats converttoutf8 initlanguages cron updatetlds runcommand ===== Popular commands ===== Two of the most commonly used sub-commands are: Processqueue (processes the available queues to send queued campaigns): phplist -pprocessqueue Process Bounces (process bounce messages received from remote servers and update subscribers bounce records): phplist -pprocessbounces ===== README.commandline ===== Commandline processing requires PHP 4.3.0 or higher. A few pages in the phpList system can since version 2.7.0 be run with a simple command from the commandline. The script to use is called "phplist" in the "bin" directory. You will have to edit this script to fit your system. The normal phpList access restrictions are bypassed, but the Unix users who are allowed to run the script should be mentioned in the "commandline_users" config variable. The identity of a user is determined by the USER environment variable, which may not always match your system. The "p" parameter is the page that needs to be run. Currently apart of "processqueue" and "processbounces" mentioned above you can also use phplist -psend. **This will require some more arguments:** * -l list * -s subject * [-f from] and you need to "pipe" the message into the script. * The -l parameter can have two types of values, the name of the list or the number of the list. You can add multiple lists or multiple -l parameters * The subject can have spaces * The from is optional. It will default to the system administrator as set up in your config. **So the full "send" command line would be:** phplist -psend -s This is the subject -l test 1 2 3 -f me@server.com < messagefile