Location: PHPKode > scripts > Mime Mailer > mime-mailer/test.php
<?
// include class
include("mimemailer.php");


$in_fromName = stripslashes($in_fromName);
$in_fromMail = stripslashes($in_fromMail);
$in_to = stripslashes($in_to);
$in_cc = stripslashes($in_cc);
$in_bcc = stripslashes($in_bcc );
$in_subject = stripslashes($in_subject);
$in_plaintext = stripslashes($in_plaintext);
$in_htmltext = stripslashes($in_htmltext);

/*
	// uncomment this and set it to appropriate default values
	$def_fromName = "";
	$def_fromMail = "";
	$def_to = "";
	$def_cc = "";
	$def_bcc = "";
	$def_subject = "";

	$def_plaintext = "Fax from Wieden & Kennedy to S&J, 8/13/1995:

Guido, Bob suggested using this fax as dummy copy.
Best, Michael.

Fax from S&J to Wieden & Kennedy, 8/14/1995:

Michael & Bob, nice idea and thanks for your fax. What do you think of adding this fax to yours? It makes your dummy copy a bit longer, so it will fit into long copy ads as well.
Very best. Guido.

Fax from Wieden & Kennedy to S&J, 8/14/1995:

Guido, Bob here. A nice idea adding your copy to ours, and we agree that the copy needs to be a bit longer. To that end, how about adding something from Oscar Wilde? How about 'I always travel with my diary. It'‘s important to have something sensational to read on the train.'
Yours truly, Bob.

Fax from S&J to Wieden & Kennedy, 8/15/1995:

Bob'n'Michael, I had a bad, bad night. I was in doubt about making the dummy copy longer. Those art directors creating ads with short copys will probably never read the end of the new dummy copy. This could create the desire to switch to brochure designers, which could, in the long run, mean the end of print advertising.
Dreadfully, Guido.

Fax from S&J to Wieden & Kennedy, 8/22/1995:

Dear Bob Michael, haven't received a message from you yet. Are you sure that you want to end your dummy copy with a fax written by me?
Waiting for your final words, Guido.

Fax from Wieden & Kennedy to S&J, 8/22/1995: No, we think it's fine if you end it.

";

	$def_htmltext  = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"';
	$def_htmltext .= '"http://www.w3.org/TR/html4/loose.dtd">';
	$def_htmltext .= '<html>';
	$def_htmltext .= '	<head>';
	$def_htmltext .= '	<title>testmail htmltext</title>';
	$def_htmltext .= '	</head>';
	$def_htmltext .= '	<body marginwidth="20" marginheight="20" topmargin="20" leftmargin="20">';
	$def_htmltext .= "
										<span style='color:#990000'>Fax from Wieden & Kennedy to S&J, 8/13/1995:</span><br>Guido, Bob suggested using this fax as dummy copy.<br>Best, Michael.<br><br>
										<span style='color:#990000'>Fax from S&J to Wieden & Kennedy, 8/14/1995:</span><br>Michael & Bob, nice idea and thanks for your fax. What do you think of adding this fax to yours? It makes your dummy copy a bit longer, so it will fit into long copy ads as well.<br>Very best. Guido.<br><br>
										<span style='color:#990000'>Fax from Wieden & Kennedy to S&J, 8/14/1995:</span><br>Guido, Bob here. A nice idea adding your copy to ours, and we agree that the copy needs to be a bit longer. To that end, how about adding something from Oscar Wilde? How about 'I always travel with my diary. It'‘s important to have something sensational to read on the train.'<br>Yours truly, Bob.<br><br>
										<span style='color:#990000'>Fax from S&J to Wieden & Kennedy, 8/15/1995:</span><br>Bob'n'Michael, I had a bad, bad night. I was in doubt about making the dummy copy longer. Those art directors creating ads with short copys will probably never read the end of the new dummy copy. This could create the desire to switch to brochure designers, which could, in the long run, mean the end of print advertising.<br>Dreadfully, Guido.<br><br>
										<span style='color:#990000'>Fax from S&J to Wieden & Kennedy, 8/22/1995:</span><br>Dear Bob Michael, haven't received a message from you yet. Are you sure that you want to end your dummy copy with a fax written by me?Waiting for your final words, Guido.<br><br>
										<span style='color:#990000'>Fax from Wieden & Kennedy to S&J, 8/22/1995:</span><br>No, we think it's fine if you end it.<br><br>
									";

	$def_htmltext .= '</body>';
	$def_htmltext .= '</html>';

*/



// should we send a message right now?
if ($in_doSend=="offwego") {

	// create new class mimemailer
	$mailer = new mimemailer('ISO-8859-1');

	// set the name and the emailadrerss of the sender
	if ($in_fromName && in_fromMail) if(!$mailer->setFrom($in_fromName, $in_fromMail)) echo "<span style='color:#990000'>hide@address.com</span><br>";

	// add a receiver of the message (several possible)
	if ($in_to) if(!$mailer->addTo($in_to)) echo "<span style='color:#990000'>hide@address.com</span><br>";

	// add a cc-receiver of the message (several possible)
	if ($in_cc) if(!$mailer->addCc($in_cc)) echo "<span style='color:#990000'>hide@address.com</span><br>";

	// add a bdd-receiver of the message (several possible)
	if ($in_bcc) if(!$mailer->addBcc($in_bcc)) echo "<span style='color:#990000'>hide@address.com</span><br>";

	// set the subject of the message
	if ($in_subject) if(!$mailer->setSubject($in_subject)) echo "<span style='color:#990000'>hide@address.com</span><br>";

	// set the plain text of the message
	if ($in_plaintext) if(!$mailer->setPlaintext($in_plaintext)) echo "<span style='color:#990000'>hide@address.com</span><br>";

	// set the htmlText text of the message
	if ($in_htmltext) if(!$mailer->setHtmltext($in_htmltext)) echo "<span style='color:#990000'>hide@address.com</span><br>";

	// add an attachment to the message (several possible)
	if ($_FILES['in_file']['tmp_name']) if(!$mailer->addAttachment($_FILES['in_file']['tmp_name'], $_FILES['in_file']['tmp_name'], $_FILES['in_file']['name'])) echo "<span style='color:#990000'>hide@address.com</span><br>";

} // end if $in_doSend=="offwego"



/*	also possible methods but not used in this example:

		function resetTo()
			delete all receivers of the message
			
		function resetCc()
			delete all cc-receivers of the message
			
		function resetBcc()
			delete all bcc-receivers of the message
			
		function resetAttachments()
			delete all attachments of the message

*/
			
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Testarea</title>
</head>
<body marginwidth="20" marginheight="20" topmargin="20" leftmargin="20">
<h1>example</h1>
<a href="test.php">reload</a><br>


<?
	// send the message
	if ($in_doSend=="offwego") {
		if (!$mailer->deliver()) {
			echo "<br><span style='color:#990000'>error sending mail</span>";
		}
		else {
			echo "<br><span style='color:#990000'>mail successfully sent</span>";
		}
	}
?>

<form name="formdoc" method="post" action="test.php" enctype="multipart/form-data">
<input name="in_doSend" type="hidden" value="offwego">
<p>

<h5>create mail</h5>

from name:<br>
<input name="in_fromName" type="text" size="30" value="<?=$def_fromName?>"><br><br>

from mail:<br>
<input name="in_fromMail" type="text" size="30" value="<?=$def_fromMail?>"><br><br>

to:<br>
<input name="in_to" type="text" size="30" value="<?=$def_to?>"><br><br>

cc:<br>
<input name="in_cc" type="text" size="30" value="<?=$def_cc?>"><br><br>

bcc:<br>
<input name="in_bcc" type="text" size="30" value="<?=$def_bcc?>"><br><br>

subject:<br>
<input name="in_subject" type="text" size="30" value="<?=$def_subject?>"><br><br>

text:<br>
<textarea name="in_plaintext" type="text" cols="50" rows="7"><?=$def_plaintext?></textarea><br><br>

htmltext:<br>
<textarea name="in_htmltext" type="text" cols="50" rows="7"><?=$def_htmltext?></textarea><br><br>

attachment<br>
<input name="in_file" type="file" size="30"><br><br>

<button name="send" type="button" value="send" onClick="document.formdoc.submit()">  send  </button>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<button name="reset" type="button" value="reset" onClick="document.formdoc.reset()">  reset  </button>
</p>
</form>

</body>
</html>
Return current item: Mime Mailer