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.

#!/usr/bin/php
<?php

/* USAGE: #./.php test@email.com '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[1]."...\n";

if (mail($argv[1], 'test email', $argv[2], $headers)){
  echo 'success!'."\n";
}else{
  echo 'failed!'."\n";
}

exit;

?>