Nou hier dan de php code in een hele ruwe form.

Zal het nog mooi aanpassen !
POSIX doet een beetje raar met php gevalletjes, dus <?
$mail = new VgouwMail();<blockquote><font size="1" face="verdana, arial, helvetica">code:</font><hr><font face="courier, fixedsys, lucida console"><nobr>$mail->setSubject('The Subject');
$mail->setReply('ReplyEmail@mail.nl');
$mail->setFrom("FromEmail@email.nl","FromPerson");
$mail->setOrganization('The Organization');
$mail->setDate(time()-(3600*30));
$mail->setId('The Id');
$mail->setPriority(1);
$mail->addHeader('x-ikke','ja ik!');
//$mail->removeHeader('x-ikke');
//$mail->clearHeaders();
//TO CC BCC
$mail->addSendT0("jezelf@ergens.nl","ToPerson1");
$mail->addSendT0("ToEmail0@email.nl","ToPerson0");
$mail->addSendT0("ToEmail1@email.nl");
$mail->addSendCC("CcEmail0@email.nl","CcPerson0");
$mail->addSendBCC("BccEmail0@email.nl","BccPerson0");
//$mail->clearSendTO();
//$mail->clearSendCC();
//$mail->clearSendBCC();
//Attachements
$mail->addAttachement(basename($PHP_SELF));
//$mail->removeAttachement(basename($PHP_SELF));
//$mail->clearAttachements();
$mail->setMailHtml('<h1>VGouwMail</h1>
This is a MIME message from VGouwMail!<br>
<b>text/html</b>.
');
$mail->setMailPlain("VGouwMail\n\n
This is a MIME message from VGouwMail!\n
text/html.
");
$mail->mail();
class VGouwMail {
/**
*Arrays containing To, Cc and Bcc email adresses and names.
*
**/
var $sendTO = Array();
var $sendTOName = Array();
var $sendCC = Array();
var $sendCCName = Array();
var $sendBCC = Array();
var $sendBCCName = Array();
var $from = '';
var $fromName = '';
var $reply = '';
var $replyName = '';
var $errors = '';
var $errorsName = '';
var $organization = '';
var $subject = '';
var $attachements = Array();
var $otherHeaders = Array();
var $priority = 3;
var $mailDate = FALSE;
var $textPlain;
var $textPlain;
var $textHtml;
var $xmailer ='VGouwMail';
var $boundries = Array();
var $messageId = '';
function CosinMail(){
}
function setId($id){
$ok = FALSE;
$id = trim($id);
if(is_string($id) || is_integer($id)){
$this->messageId = $id;
$ok = TRUE;
}
return $ok;
}
function getBoundry($nr){
$boundry = null;
while (!isset($this->boundries[$nr]) || in_array($boundry,$this->boundries)){
srand((double)microtime()*96545624);
$this->boundries[$nr] = $this->xmailer.'_'.md5(uniqid(rand())).'_BoUnDaRy'.$nr;
}
return $this->boundries[$nr];
}
function setMailPlain($msg){
$ok = FALSE;
if(is_string($msg) || is_integer($msg)){
$this->textPlain = $msg;
$ok = TRUE;
}
return $ok;
}
function setMailHtml($msg){
$ok = FALSE;
if(is_string($msg) || is_integer($msg)){
$this->textHtml = $msg;
$ok = TRUE;
}
return $ok;
}
function setDate($mailDate){
$ok = FALSE;
if((is_integer($mailDate) && $mailDate > -1) || $mailDate === FALSE){
$this->mailDate = $mailDate;
$ok = TRUE;
}
return $ok;
}
function getHeaders(){
$hd = null;
if($this->messageId !== '')
$hd .= 'Message-Id: <'.$this->messageId.">\r\n";
$nbo = count($this->sendCC);
if($nbo > 0){
$hd .='Cc: ';
for($nr = 0 ; $nr < $nbo ; $nr++){
if(isset($this->sendCCName[$this->sendCC[$nr]]))
$hd .= '"' .$this->sendCCName[$this->sendCC[$nr]] .'" ';
$hd .= '<'.$this->sendCC[$nr].'>';
if($nr < $nbo-1)
$hd .=',';
}
$hd .= "\r\n";
}
$nbo = count($this->sendBCC);
if($nbo > 0){
$hd .='Bcc: ';
for($nr = 0 ; $nr < $nbo ; $nr++){
if(isset($this->sendBCCName[$this->sendBCC[$nr]]))
$hd .= '"' .$this->sendBCCName[$this->sendBCC[$nr]] .'" ';
$hd .= '<'.$this->sendBCC[$nr].'>';
if($nr < $nbo-1)
$hd .=',';
}
$hd .= "\r\n";
}
if($this->from !== ''){
$hd .= 'From: ';
if($this->fromName !== '')
$hd.= '"'.$this->fromName.'" ';
$hd .= '<'.$this->from.'>'."\r\n";
}
if($this->reply !== ''){
$hd .= 'Reply-To: ';
if($this->replyName !== '')
$hd .= '"'.$this->replyName.'" ';
$hd .= '<'.$this->reply .'>' ."\r\n";
}
if($this->errors !== ''){
$hd .= 'Errors-To: ';
if($this->errorsName !== '')
$hd .= '"'.$this->errorsName.'" ';
$hd .= '<'.$this->errors .'>' ."\r\n";
}
$hd .= 'Date: ';
if($this->mailDate !== FALSE)
$hd .= date('r',$this->mailDate) ."\r\n";
else
$hd .= date('r') ."\r\n";
if($this->organization !== '')
$hd .= 'Organization: '.$this->organization."\r\n";
$hd .='MIME-Version: 1.0'."\r\n";
$hd .='Content-Type: multipart/mixed;'."\r\n\t".'boundary="'.$this->getBoundry(0).'"'."\r\n";
if($this->priority !== 3){
$hd .= 'X-Priority: ' .$this->priority ."\r\n";
}
$hd .= 'X-Mailer: ' .$this->xmailer."\r\n";
$nbo = count($this->otherHeaders);
$keys = array_keys($this->otherHeaders);
for($nr = 0 ; $nr < $nbo ; $nr++){
$hd .= $keys[$nr] .': ' .$this->otherHeaders[$keys[$nr]];
}
return $hd;
}
function getTo(){
$nbo = count($this->sendTO);
for($nr = 0 ; $nr < $nbo ; $nr++){
if(isset($this->sendTOName[$this->sendTO[$nr]]))
$to .= '"'.$this->sendTOName[$this->sendTO[$nr]] .'"';
$to .= '<'.$this->sendTO[$nr].'>';
if($nr < $nbo-1)
$to .=',';
}
return $to;
}
function getMessage(){
$msg = "This is a multi-part message in MIME format.\r\n\r\n";
$msg .= '--'.$this->getBoundry(0) ."\r\n";
$msg .='Content-Type: multipart/alternative;'."\r\n\t";
$msg .='boundary="'.$this->getBoundry(1)."\"\r\n\r\n";
$msg .= $this->getBoundry(1) ."\r\n";
$msg .= 'Content-Type: text/plain;' ."\r\n\t";
$msg .= 'charset="iso-8859-1"' ."\r\n";
$msg .= 'Content-Transfer-Encoding: quoted-printable'."\r\n\r\n";
$msg .= $this->textPlain ."\r\n\r\n";
$msg .= '--'.$this->getBoundry(1) ."\r\n";
$msg .= 'Content-Type: text/html;' ."\r\n\t";
$msg .= 'charset="iso-8859-1"' ."\r\n";
$msg .= 'Content-Transfer-Encoding: quoted-printable'."\r\n\r\n";
$msg .= $this->textHtml ."\r\n\r\n";
$msg .= '--'.$this->getBoundry(1) ."--\r\n\r\n";
$nbo = count($this->attachements);
$keys = array_keys($this->attachements);
for($nr = 0 ; $nr < $nbo ; $nr++){
$fileName = basename($keys[$nr]);
$extension = substr(strrchr($keys[$nr], "."),1);
$msg .= '--'.$this->getBoundry(0) ."\r\n";
$msg .= 'Content-Type: '.$this->attachements[$keys[$nr]].';'."\r\n\t".'name="'.$fileName.'"' ."\r\n";
$msg .= 'Content-Transfer-Encoding: base64' ."\r\n";
$msg .= 'Content-Disposition: attachment;'."\r\n\t".'filename="'.$fileName.'"'."\r\n\r\n";
$msg .= $this->encodeAttachement($keys[$nr])."\r\n";
}
$msg .= '--'.$this->getBoundry(0) ."--\r\n";
return $msg;
}
function mail(){
$to = $this->getTo();
$hd = $this->getHeaders();
$msg =$this->getMessage();
$this->boundries = Array();
mail($to,$this->subject,$msg,$hd);
echo('<pre>'.htmlspecialchars('To: '.$to."\r\n".$hd )."\r\n\r\n".$msg.'</pre>');
}
function setPriority($priority){
$ok = FALSE;
$priority = (integer) $priority;
if($priority > 0 && $priority < 6){
$this->priority = $priority;
$ok = TRUE;
}
return $ok;
}
/**
* [public boolean]
* Adds an file as an attachement to the mail.
* When the file exists and the file is readable the attachement is added and true is returned.
* When the file can not be found is not readable or is an directory false is returned.
*/
function addAttachement($file,$mimeType = null){
$ok = FALSE;
$file = trim($file);
if(!is_dir($file) && file_exists($file) && is_readable($file) && !isset($atachements[$file])){
if($mimeType === null){
$extension = substr(strrchr($file, "."),1);
$mimeType = getMimeType($extension);
}
$this->attachements[$file] = $mimeType;
$ok = TRUE;
}
return $ok;
}
/**
* [public boolean]
* Removes an attachement from the message.
* When the attachement with the specified name is not an attachement false is returned els true.
*/
function removeAttachement($file){
$removed = FALSE;
if(isset($this->attachements[$file])){
unset($this->attachements[$file]);
}
}
/**
* [private string]
* Base64 encodes an file. On succes the ecode file is returnes as an string els false is returned.
*/
function encodeAttachement($file){
$encoded = FALSE;
$file = trim($file);
if(file_exists($file) && is_readable($file)){
$fp = fopen($file,'r');
$encoded = chunk_split(base64_encode(fread($fp, filesize($file))));
&a