Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
fdl_sendmail.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5  * @package FDL
6 */
7 /**
8  * Send mail using freedom sendmail
9  *
10  * @author Anakeen 2007
11  * @version $Id: fdl_sendmail.php,v 1.1 2007/01/19 16:24:03 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage
15  */
16 /**
17  */
18 
19 include_once ("FDL/sendmail.php");
20 
21 $to = GetHttpVars("to");
22 $cc = GetHttpVars("cc");
23 $bcc = GetHttpVars("bcc");
24 $subject = GetHttpVars("subject");
25 $file = GetHttpVars("file");
26 $htmlmode = GetHttpVars("htmlmode");
27 
28 $from = getMailAddr($action->user->id);
29 if ($from == "") $from = getParam('SMTP_FROM');
30 if ($from == "") $from = $from = $action->user->login . '@' . php_uname('n');
31 
33 if ($file && $file != 'stdin') {
34  $mime = trim(shell_exec(sprintf("file -ib %s", escapeshellarg($file))));
35  if (preg_match("|text/html|", $mime)) {
36  $themail->setHTMLBody($file, true);
37  } else if (preg_match("|text|", $mime)) {
38  $themail->setTxtBody($file, true);
39  } else {
40  $themail->addAttachment($file, $mime);
41  }
42 } else {
43  // stream_set_blocking(STDIN,0);
44  if ($file = 'stdin') {
45  $out = "";
46  $line = true;
47  while ($line !== false) {
48  $line = fgets(STDIN);
49  $out.= "$line\n";
50  }
51  if ($htmlmode == "Y") $themail->setHTMLBody($out, false);
52  else $themail->setTxtBody($out, false);
53  }
54 }
55 
56 if ($subject == "") $subject = basename($file);
57 if ($subject == "") $subject = _("no subject");
59 if ($err) print "Error:$err\n";
60 ?>
← centre documentaire © anakeen - published under CC License - Dynacase