make graph quite a bit better: nicer defaults, more extra options
[php-utility-classes.git] / include / classes / email.php-class
index 0ea1698b3a5fc26ab18f8def1e84915e1498d5c8..5f6454a3835ea432a0cbd3496c3700a4d38e9db3 100755 (executable)
@@ -1,4 +1,24 @@
 <?php
+/* ***** BEGIN LICENSE BLOCK *****
+ *
+ * The contents of this file are subject to Austrian copyright reegulations
+ * ("Urheberrecht"); you may not use this file except in compliance with
+ * those laws.
+ * This contents and any derived work, if it gets distributed in any way,
+ * is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
+ * either express or implied.
+ *
+ * The Original Code is KaiRo's E-Mail module.
+ *
+ * The Initial Developer of the Original Code is
+ * KaiRo - Robert Kaiser.
+ * Portions created by the Initial Developer are Copyright (C) 2003-2004
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Robert Kaiser <kairo@kairo.at>
+ *
+ * ***** END LICENSE BLOCK ***** */
+
 class email {
   // email PHP class
   // class/object for creating a new mail and send it
@@ -76,6 +96,9 @@ class email {
   // function addMailText($textpart)
   //   add some text to the mail
   //
+  // function addAttachment($aname, $acontent, [$atype])
+  //   add an attachment to the mail, use given file name, content and MIME type (defaults to application/octet-stream)
+  //
   // function send()
   //   really send the mail
   //
@@ -177,13 +200,20 @@ class email {
       }
     }
     if (count($this->attachments)) {
-      $boundary = "KaiRoJVPSteyr1030713";
+      // create random boundary, 20 chars, always beginning with KaiRo ;-)
+      $boundary = 'KaiRo';
+      for ($i=1; $i<=15; $i++) {
+        $r=rand(0,61);
+        if ($r<10) { $boundary .= chr($r+48); }
+        elseif ($r<36) { $boundary .= chr($r+55); }
+        elseif ($r<62) { $boundary .= chr($r+61); }
+      }
       $hdrs .= "Content-Type: multipart/mixed; boundary=\"$boundary\";\n";
       $hdrs .= "Content-Transfer-Encoding: 7bit\n";
       $mtxt .= "This part of the E-mail should never be seen. If\n";
       $mtxt .= "you are reading this, consider upgrading your e-mail\n";
       $mtxt .= "client to a MIME-compatible client.\n";
-      $mtxt .= "--$boundary\n";
+      $mtxt .= "\n--$boundary\n";
       if (ereg("text/.*", $this->content_type)) {
         $mtxt .= "Content-Type: ".$this->content_type."; charset=\"".$this->charset."\"\n";
       }
@@ -204,7 +234,7 @@ class email {
     $mtxt .= stripslashes($this->mailtext);
     if (count($this->attachments)) {
       foreach ($this->attachments as $attach) {
-        $mtxt .= "--$boundary\n";
+        $mtxt .= "\n--$boundary\n";
         $mtxt .= "Content-Type: ".$attach["type"]."; name=\"".$attach["name"]."\";\n";
         $mtxt .= "Content-Transfer-Encoding: base64\n";
         $mtxt .= "Content-Disposition: attachment\n\n";