Here is a simple php script that sends an email from the command line using php. It sort of assumes you have the PHP CLI installed (“#apt-get install php5-cli” on debian). The aim is for a quick way you can test if your localhost SMTP server is sending emails from PHP. Of course there are some more sophisticated classes written if you need to do something fancy.


/* USAGE: #./.php 'this is a bit of text' */

$headers = 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n";
$headers .= 'From: Command Line' . "\n\n";

echo "Sending mail to ".$argv&#91;1&#93;."...\n";

if (mail($argv&#91;1&#93;, 'test email', $argv&#91;2&#93;, $headers)){
  echo 'success!'."\n";
  echo 'failed!'."\n";