| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- class ImtMail
- {
- function ImtMail()
- {
- }
-
- public static function sendMail( $to , $from, $reply, $subject, $message, $lang = 'fr', $contentName = null, $contentType = null, $content = null )
- {
- $boundaries = "_parties_".md5(uniqid (rand()));
-
- $to = "\"$to\" <$to>";
-
- $mime = "Date: ".date("D, j M Y G:i:s O")."\r\n";
- $mime .= "MIME-Version: 1.0\r\n";
- $mime .= "Content-Type: multipart/alternative;\r\n";
- $mime .= "\tboundary=\"$boundaries\"\r\n\r\n";
-
- if ($lang == 'fr' || $lang == 'FR')
- $mimeTxt = 'Ce message est au format MIME.';
- else
- $mimeTxt = 'This message is in MIME format.';
-
- $body = $mimeTxt . "\r\n\r\n" . "--" . $boundaries . "\r\n";
- $body .= "Content-Type: text/plain;\r\n";
- $body .= "\tcharset=\"iso-8859-1\"\r\n";
- $body .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
- $body .= $message . "\r\n";
-
- $body .= "--" . $boundaries . "\r\n";
- $body .= "Content-Type: text/html;\r\n";
- $body .= "\tcharset=\"iso-8859-1\"\r\n";
- $body .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
- $body .= $message . "\r\n";
-
- if ($contentName)
- {
- $attachment = "--" . $boundaries . "\r\n";
- $attachment .= "Content-Type: \"$contentType\"; name=\"$contentName\"\r\n";
- $attachment .= "Content-Transfer-Encoding: base64\r\n";
- $attachment .= "Content-Disposition: attachment; filename=\"$contentName\"\r\n\r\n";
- $attachment .= chunk_split(base64_encode($content));
- $attachment .= "\r\n\r\n\r\n";
- $body .= $attachment;
- }
-
- $body = $body . "--" . $boundaries . "--\r\n";
-
- $additionnalHeaders = "Reply-to: \"$reply\" <$reply>\r\nFrom: \"$from\" <$from>\r\n".$mime;
-
- return mail($to, $subject, $body, $additionnalHeaders);
- }
- }
- ?>
|