Permalink
Browse files

phail - Stands for PHp mAIL a console PHP replacement for the mail

Unix command


git-svn-id: http://svn.php.net/repository/pear/packages/Mail_Mime/trunk@78786 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent 787674b commit 85aa05121c61b58e9fc30c1d81b9c35f9a4fb3dc @tvvcox tvvcox committed Apr 19, 2002
Showing with 47 additions and 0 deletions.
  1. +47 −0 scripts/phail.php
View
@@ -0,0 +1,47 @@
+#!@prefix@/bin/php -Cq
+<?php
+/**
+* PHAIL - stands for PHP Mail
+* @author Tomas V.V.Cox <cox@idecnet.com>
+*/
+require_once 'Mail.php';
+require_once 'Mail/mime.php';
+require_once 'Console/Getopt.php';
+
+$argv = Console_Getopt::readPHPArgv();
+$opts = Console_Getopt::getOpt($argv, 'f:c:s:t:a:b:');
+if (PEAR::isError($opts)) {
+ usage($opts->getMessage());
+}
+
+PEAR::setErrorHandling(PEAR_ERROR_DIE);
+$mime = &new Mail_Mime;
+foreach ($opts[0] as $opt) {
+ $param = $opt[1];
+ switch ($opt[0]) {
+ case 'f':
+ $headers['From'] = $param; break;
+ case 'c':
+ $headers['Cc'] = $param; break;
+ case 's':
+ $headers['Subject'] = $param; break;
+ case 't':
+ $to = $param; break;
+ case 'a':
+ $mime->addAttachment($param); break;
+ case 'b':
+ $isfile = @is_file($param) ? true : false;
+ $mime->setTXTBody($param, $isfile); break;
+ }
+}
+
+$mbody = $mime->get();
+$headers = $mime->headers($headers);
+$mail =& Mail::factory('mail');
+$mail->send($to, $headers, $mbody);
+
+function usage($error)
+{
+ die($error);
+}
+?>

0 comments on commit 85aa051

Please sign in to comment.