diff --git a/doc/dev/php/html/CMailFile_8class_8php-source.html b/doc/dev/php/html/CMailFile_8class_8php-source.html index a2d3f73a0ba..140687e8af8 100644 --- a/doc/dev/php/html/CMailFile_8class_8php-source.html +++ b/doc/dev/php/html/CMailFile_8class_8php-source.html @@ -42,115 +42,116 @@ 00065 { 00066 $this->subject = $subject; 00067 $this->addr_to = $to; -00068 $this->smtp_headers = $this->write_smtpheaders($from,$addr_cc); -00069 $this->text_body = $this->write_body($msg, $filename_list); +00068 $this->smtp_headers = $this->write_smtpheaders($from,$addr_cc); +00069 $this->text_body = $this->write_body($msg, $filename_list); 00070 if (count($filename_list)) { -00071 $this->mime_headers = $this->write_mimeheaders($filename_list, $mimefilename_list); -00072 $this->text_encoded = $this->attach_file($filename_list,$mimetype_list,$mimefilename_list); +00071 $this->mime_headers = $this->write_mimeheaders($filename_list, $mimefilename_list); +00072 $this->text_encoded = $this->attach_file($filename_list,$mimetype_list,$mimefilename_list); 00073 } 00074 } 00075 -00076 function attach_file($filename_list,$mimetype_list,$mimefilename_list) -00077 { -00078 for ($i = 0; $i < count($filename_list); $i++) { -00079 $encoded = $this->encode_file($filename_list[$i]); -00080 if ($mimefilename_list[$i]) $filename_list[$i] = $mimefilename_list[$i]; -00081 $out = $out . "--" . $this->mime_boundary . "\n"; -00082 if (! $mimetype_list[$i]) { $mimetype_list[$i] = "application/octet-stream"; } -00083 $out = $out . "Content-type: " . $mimetype_list[$i] . "; name=\"$filename_list[$i]\";\n"; -00084 $out = $out . "Content-Transfer-Encoding: base64\n"; -00085 $out = $out . "Content-disposition: attachment; filename=\"$filename_list[$i]\"\n\n"; -00086 $out = $out . $encoded . "\n"; -00087 } -00088 $out = $out . "--" . $this->mime_boundary . "--" . "\n"; -00089 return $out; -00090 // added -- to notify email client attachment is done -00091 } -00092 -00093 function encode_file($sourcefile) -00094 { -00095 // print "<pre> on encode $sourcefile </pre>\n"; -00096 if (is_readable($sourcefile)) -00097 { -00098 $fd = fopen($sourcefile, "r"); -00099 $contents = fread($fd, filesize($sourcefile)); -00100 $encoded = my_chunk_split(base64_encode($contents)); -00101 fclose($fd); -00102 } -00103 return $encoded; -00104 } -00105 -00106 function sendfile() -00107 { -00108 $headers .= $this->smtp_headers . $this->mime_headers; -00109 $message = $this->text_body . $this->text_encoded; -00110 return mail($this->addr_to,$this->subject,stripslashes($message),$headers); -00111 } -00112 -00113 function write_body($msgtext, $filename_list) -00114 { -00115 if (count($filename_list)) -00116 { -00117 $out = "--" . $this->mime_boundary . "\n"; -00118 $out = $out . "Content-Type: text/plain; charset=\"iso8859-15\"\n\n"; -00119 // $out = $out . "Content-Type: text/plain; charset=\"us-ascii\"\n\n"; -00120 } -00121 $out = $out . $msgtext . "\n"; -00122 return $out; -00123 } -00124 -00125 function write_mimeheaders($filename_list, $mimefilename_list) { -00126 $out = "MIME-version: 1.0\n"; -00127 $out = $out . "Content-type: multipart/mixed; "; -00128 $out = $out . "boundary=\"$this->mime_boundary\"\n"; -00129 $out = $out . "Content-transfer-encoding: 7BIT\n"; -00130 for($i = 0; $i < count($filename_list); $i++) { -00131 if ($mimefilename_list[$i]) $filename_list[$i] = $mimefilename_list[$i]; -00132 $out = $out . "X-attachments: $filename_list[$i];\n\n"; -00133 } -00134 return $out; -00135 } -00136 -00137 function write_smtpheaders($addr_from,$addr_cc) -00138 { -00139 $out = "From: $addr_from\n"; -00140 if($addr_cc != "") -00141 $out = $out . "Cc: $addr_cc\n"; -00142 $out = $out . "Reply-To: $addr_from\n"; -00143 $out = $out . "X-Mailer: Dolibarr version " . DOL_VERSION ."\n"; -00144 $out = $out . "X-Sender: $addr_from\n"; -00145 return $out; -00146 } -00147 } -00148 -00149 // usage - mimetype example "image/gif" -00150 // $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filename,$mimetype); -00151 // $mailfile->sendfile(); -00152 -00153 // Splits a string by RFC2045 semantics (76 chars per line, end with \r\n). -00154 // This is not in all PHP versions so I define one here manuall. -00155 function my_chunk_split($str) -00156 { -00157 $stmp = $str; -00158 $len = strlen($stmp); -00159 $out = ""; -00160 while ($len > 0) { -00161 if ($len >= 76) { -00162 $out = $out . substr($stmp, 0, 76) . "\r\n"; -00163 $stmp = substr($stmp, 76); -00164 $len = $len - 76; -00165 } -00166 else { -00167 $out = $out . $stmp . "\r\n"; -00168 $stmp = ""; $len = 0; -00169 } -00170 } -00171 return $out; -00172 } -00173 -00174 // end script -00175 ?> -
1.3.7