<?
// Module de gestion des emails
// Ecrit par Sébastien DIAZ
// Distribue sous license GPL
if (! defined("MAILS"))
{
define("MAILS",1);
class mails
{
var $boundary; // Boundary du mail
var $header; // Header du mail
var $charset; // charset du mail
var $type; // content type du mail
var $transfert_encoding; // Transfert encoding
var $sender; // Expediteur
var $recipient; // Destinataire
var $subject; // Sujet
var $message;
function mails() // Constructeur
{
$this->boundary = "-----=".md5(uniqid(rand()));
$this->header = "MIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"$this->boundary\"\r\n\r\n";
$this->charset="iso-8859-1";
$this->type="text/plain";
$this->transfert_encoding="8bit";
$this->message="";
}
function send()
{
$hmessage="Je vous informe que ceci est un message au format MIME 1.0 multipart/mixed.\r\n";
$hmessage.="--$this->boundary\r\n";
$hmessage.="Content-Type: $this->type; charset=\"$this->charset\"\r\n";
$hmessage.="Content-Transfer-Encoding: $this->transfert_encoding\r\n\r\n";
$this->message=$hmessage.$this->message;
mail($this->recipient, $this->subject, $this->message, "Reply-to: $$this->sender\r\nFrom: $this->sender\r\n".$this->header);
}
function attach($file, $type)
{
$fp = fopen($file, "rb");
$attachment = fread($fp, filesize($file));
fclose($fp);
$attachment = chunk_split(base64_encode($attachment));
$this->message .= "--$this->boundary\r\n";
$this->message .= "Content-Type: $type; name=\"$file\"\r\n";
$this->message .= "Content-Transfer-Encoding: base64\r\n";
$this->message .= "Content-Disposition: inline; filename=\"$file\"\r\n";
$this->message .= "\r\n";
$this->message .= $attachment . "\r\n";
$this->message .= "\r\n\r\n";
$this->message .= "--$this->boundary--\r\n";
}
}
}
?>