<?php
/*
This file is part of Thomas Bley's moregroupware webmail2/calendar2/admin2 module. (tb-mgw)

More information:
-----------------

Simple Groupware Solutions Thomas Bley
Fichtenstr. 23
Germany, 85640 Putzbrunn

Contact:
--------

info@simple-groupware.de

http://www.simple-groupware.de


Copyright 2002-2003 Thomas Bley
tb-mgw is distributed under the terms of the GNU General Public License 

tb-mgw is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

tb-mgw is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with tb-mgw; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

// Builder
// Moregroupware.org

/**
* Filename.......: example.2.php
* Project........: HTML Mime Mail class
* Last Modified..: 15 July 2002
*/
	error_reporting(E_ALL);
	include('htmlMimeMail.php');

/**
* Example of usage. This example shows
* how to use the class with html,
* embedded images, no attachments, but
* using the third argument of setHtml(),
* which will try to automatically find the
* images (though not limited to images),
* and embed them. It will send the mail
* using built in php mail() functionality.
*
* Create the mail object.
* No header argument any more
*/
	$mail = new htmlMimeMail();
	
/**
* Read the image background.gif into
* $background
*/
	$mail->setCrlf("\r\n");
//	$background = $mail->getFile('background.gif');

//    $attachment = $mail->getFile('../../docu/MGW_0-66_Webmail_manual.pdf');
	
/**
* If sending an html email, then these
* two variables specify the text and
* html versions of the mail. Don't
* have to be named as these are. Just
* make sure the names tie in to the
* $mail->setHtml() call further down.
*/
	$html = $mail->getFile(dirname("http://".$_SERVER["SERVER_NAME"].":8080".$_SERVER["SCRIPT_NAME"]).'/../../docu/docu1.php');
	
/**
* Add the text, html and embedded images.
* Here we're using the third argument of
* setHtml(), which is the path to the
* directory that holds the images. By
* adding this third argument, the class
* will try to find all the images in the
* html, and auto load them in. Not 100%
* accurate, and you MUST enclose your
* image references in quotes, so src="img.jpg"
* and NOT src=img.jpg. Also, where possible,
* duplicates will be avoided.
*/
    
    $html = str_replace("img/","",$html);
    
/*
    $text = strip_tags(str_replace(array("\n","\r","<br>"),array("","","#@#mybr#@#"),trim($html)));
    $text = preg_replace("/(\015\012)|(\015)|(\012)/","",$text);
    $text = str_replace("#@#mybr#@#","\r\n",$text);
    
    $text = str_replace("&nbsp;"," ",$text);
*/
    
	$mail->setHtml($html, '', '../../docu/img/');
	
/**
* Sends the message.
*/
/*	$mail->setFrom('Thomas Bley <thomas.bley@simple-groupware.de>');
	$mail->setSubject('Small Webmail Manual #1');
    $mail->addAttachment($attachment, '../../docu/MGW_0-66_Webmail_manual.pdf', 'application/pdf');

	$mail->buildMessage();
	
    $email = $mail->getRFC822(array('more.groupware users'));
    $fp = fopen("../../docu/docu1.eml","w");
    fwrite($fp,$email);
    fclose($fp);
    echo "finish.<br>";
//	$result = $mail->send(array('postmaster@localhost'));
	
//	echo $result ? 'Mail sent!' : 'Failed to send mail';
*/
	$mail = new htmlMimeMail();
	$mail->setCrlf("\r\n");
//    $attachment = $mail->getFile('../../docu/MGW_0-67_Webmail_manual.pdf');
	$html = $mail->getFile(dirname("http://".$_SERVER["SERVER_NAME"].":8080".$_SERVER["SCRIPT_NAME"]).'/../../docu/docu1.php');
	
    $html = str_replace("img/","",$html);
    
	$mail->setHtml($html, '', '../../docu/img/');
	
	$mail->setFrom('Thomas Bley <thomas.bley@simple-groupware.de>');
	$mail->setSubject('Welcome to more.groupware Webmail');

//    $mail->addAttachment($attachment, '../../docu/MGW_0-67_Webmail_manual.pdf', 'application/pdf');

	$mail->buildMessage();
	
    $email = $mail->getRFC822(array('more.groupware users'));
    $fp = fopen("../../docu/docu1.eml","w");
    fwrite($fp,$email);
    fclose($fp);
    echo "finish #1a.";
    
/*

	$mail = new htmlMimeMail();
	$mail->setCrlf("\r\n");
    $attachment = $mail->getFile('../../docu/MGW_0-65_to_0-66_Webmail_Update_manual.pdf');
	$html = $mail->getFile(dirname("http://".$_SERVER["SERVER_NAME"].":8080".$_SERVER["SCRIPT_NAME"]).'/../../docu/docu2.php');
	
    $html = str_replace("img/","",$html);
    
	$mail->setHtml($html, '', '../../docu/img/');
	
	$mail->setFrom('Thomas Bley <thomas.bley@simple-groupware.de>');
	$mail->setSubject('Webmail Update Manual 0-65 to 0-66');

    $mail->addAttachment($attachment, '../../docu/MGW_0-65_to_0-66_Webmail_Update_manual.pdf', 'application/pdf');

	$mail->buildMessage();
	
    $email = $mail->getRFC822(array('MoreGroupWare-User'));
    $fp = fopen("../../docu/docu2.eml","w");
    fwrite($fp,$email);
    fclose($fp);
    echo "finish #2.";
    

	$mail = new htmlMimeMail();
	$mail->setCrlf("\r\n");
    $attachment = $mail->getFile('../../docu/MGW_0-66_to_0-67_Webmail_Update_manual.pdf');
	$html = $mail->getFile(dirname("http://".$_SERVER["SERVER_NAME"].":8080".$_SERVER["SCRIPT_NAME"]).'/../../docu/docu3.php');
	
    $html = str_replace("img/","",$html);
    
	$mail->setHtml($html, '', '../../docu/img/');
	
	$mail->setFrom('Thomas Bley <thomas.bley@simple-groupware.de>');
	$mail->setSubject('Webmail Update Manual 0-66 to 0-67');

    $mail->addAttachment($attachment, '../../docu/MGW_0-66_to_0-67_Webmail_Update_manual.pdf', 'application/pdf');

	$mail->buildMessage();
	
    $email = $mail->getRFC822(array('MoreGroupWare-User'));
    $fp = fopen("../../docu/docu3.eml","w");
    fwrite($fp,$email);
    fclose($fp);
    echo "finish #2.";    
*/
?>