User Tools

Site Tools


system:commandline

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
system:commandline [2018/11/26 00:45]
suela_phplist.com [README.commandline]
system:commandline [2018/11/26 00:46] (current)
suela_phplist.com [Commandline processing requires PHP 4.3.0 or higher]
Line 1: Line 1:
 +====== 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 
 +
 +<​code>​php -v</​code>​
 +
 +This should return something similar to the following:
 +
 +<​code>​
 +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
 +</​code>​
 +
 +
 +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
 +
 +<​code>/​usr/​local/​bin/​phplist</​code>​
 +
 +With the following content, replacing the paths with what is appropriate for your environment:​
 +
 +<​code>​
 +#!/bin/bash
 +
 +/​usr/​bin/​php /​path/​to/​your/​phplist/​lists/​admin/​index.php -c /​path/​to/​your/​phplist/​lists/​config/​config.php $*
 +</​code>​
 +
 +Make it executable:
 +
 +<​code>​chmod 755 /​usr/​local/​bin/​phplist</​code>​
 +
 +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.:
 +
 +<​code>​
 +./​bin/​phplist -pprocessqueue
 +</​code>​
 +
 +===== 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:
 +
 +<​code>​
 +dbcheck
 +send
 +processqueue
 +processbounces
 +import
 +upgrade
 +convertstats
 +reindex
 +blacklistemail
 +systemstats
 +converttoutf8
 +initlanguages
 +cron
 +updatetlds
 +runcommand
 +</​code>​
 +
 +===== Popular commands =====
 +
 +Two of the most commonly used sub-commands are:
 +
 +Processqueue (processes the available queues to send queued campaigns):
 +
 +<​code>​
 +phplist -pprocessqueue
 +</​code>​
 +
 +Process Bounces (process bounce messages received from remote servers and update subscribers bounce records):
 +
 +<​code>​
 +phplist -pprocessbounces
 +</​code>​
 +
 +===== 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
  
system/commandline.txt · Last modified: 2018/11/26 00:46 by suela_phplist.com

Resources
Contact Us

e: info@phplist.com

Boring Bit

phpList is a registered limited company

UK Company No. 07582966

VAT Registration 122 0788 37

© phpList 2016