hmm ved sq ik lige hvilken del af koden som gør det:-(
poster lige hele filen
index.php
------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<?php
function multitypemail($nickk,$msnn,$webb,$alderr,$tlff,$mobill,$statuss,$citatt,$drikk,$bommertt,$ishtml,$subject,$toname,$toemail,$fromname,$fromemail,$attachmentloc,$attfilename,$cc,$ccname,$bcc,$bccname,$maill) {
//$message - text or html message to be sent
//$msnn - indtast din msn
//$ishtml - flag set to true if $message is HTML, otherwise set to false
//$subject - subject line of email
//$toname - name of person receiving email (use only if sending to a single person)
//$toemail - email address of recipient (separate multiple addresses by a comma, use ! as first character to send to each receipient separately
//$fromname - name of person sending email
//$fromemail - email address of sender
//$attachmentloc - path and filename of attachment (on the server), or empty string for no attachment
//$attfilename - filename and extension only
//$cc - email address of person to courtesy copy (or empty string)
//$cc - name of person to courtesy copy (or empty string)
//$bcc - email address of person to blind courtesy copy (or empty string)
//$bcc - address of person to blind courtesy copy (or empty string)
$returnval=0; // returns integer, zero for success (okay, its a bit naff but at least it says something!)
global $HTTP_HOST; // name of host used for a base-reference, e.g.
www.myhost.com /* ************************** */
/* Begin local procedures */
/* ************************** */
//strip out all non-safe HTML directives and any PHP & ASP directives
function safeHTML($str)
{
$approvedtags = array(
"p"=>2, // 2 means accept all qualifiers: <foo bar>
"b"=>1, // 1 means accept the tag only: <foo>
"i"=>1, // note, recommend not allowing <img> as these can be used to call cgi-perl routines
"a"=>2,
"em"=>1,
"br"=>1,
"strong"=>1,
"blockquote"=>1,
"tt"=>1,
"hr"=>1,
"li"=>1,
"ol"=>1,
"ul"=>1
);
$str = stripslashes($str);
$str = eregi_replace("<[[:space:]]*([^>]*)[[:space:]]*>","<\\1>",$str);
$str = eregi_replace("<a([^>]*)href=\"?([^\"]*)\"?([^>]*)>",
"<a href=%22/2/%22>", $str);
$tmp = "";
while (eregi("<([^> ]*)([^>]*)>",$str,$reg))
{
$i = strpos($str,$reg[0]);
$l = strlen($reg[0]);
if ($reg[1][0] == "/")
$tag = strtolower(substr($reg[1],1));
else
$tag = strtolower($reg[1]);
if ($a = $approvedtags[$tag])
if ($reg[1][0] == "/")
$tag = "</$tag>";
elseif ($a == 1)
$tag = "<$tag>";
else
$tag = "<$tag " . $reg[2] . ">";
else
$tag = "";
$tmp .= substr($str,0,$i) . $tag;
$str = substr($str,$i+$l);
}
$str = $tmp . $str;
// Squash PHP tags unconditionally
$str = ereg_replace("<\?php","",$str);
$str = ereg_replace("<\?","",$str);
// Squash ASP tags unconditionally
$str = ereg_replace("</a><%","",$str);
return $str;
} // end safeHTML
// check if email address is valid
function validate_email($val)
{
if($val != "") {
$pattern = "/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/";
if(preg_match($pattern, $val))
return true;
else
return false;
}
else
return false;
}
/* ************************** */
/* End local procedures */
/* ************************** */
if ($ishtml) {
$txtmessage="This is a multi-part HTML-based message. Please use an HTML compliant email client.";
$fromname=safeHTML($fromname);
}
else {
// if its raw text, create a simple HTML version of it for HTML compatible email clients
$txtmessage=$fromname; // save rawtext version
//next line translates text into HTML using the PHP built-in function 'htmlentities'
$fromname="<HTML><HEAD><TITLE>MultiMail Message</TITLE></HEAD><BODY>".htmlentities($fromname,ENT_QUOTES)."</BODY></HTML>";
$fromname=nl2br($fromname); //turn all hard coded newlines into HTML breaks
}
if ($ishtml) {
$txtmessagee="This is a multi-part HTML-based message. Please use an HTML compliant email client.";
$maill=safeHTML($maill);
}
else {
// if its raw text, create a simple HTML version of it for HTML compatible email clients
$txtmessagee=$maill; // save rawtext version
//next line translates text into HTML using the PHP built-in function 'htmlentities'
$maill="<HTML><HEAD><TITLE>MultiMail Message</TITLE></HEAD><BODY>".htmlentities($maill,ENT_QUOTES)."</BODY></HTML>";
$maill=nl2br($maill); //turn all hard coded newlines into HTML breaks
}
if ($ishtml) {
$txtmessagee="This is a multi-part HTML-based message. Please use an HTML compliant email client.";
$nickk=safeHTML($nickk);
}
else {
// if its raw text, create a simple HTML version of it for HTML compatible email clients
$txtmessagee=$nickk; // save rawtext version
//next line translates text into HTML using the PHP built-in function 'htmlentities'
$nickk="<HTML><HEAD><TITLE>MultiMail Message</TITLE></HEAD><BODY>".htmlentities($nickk,ENT_QUOTES)."</BODY></HTML>";
$nickk=nl2br($nickk); //turn all hard coded newlines into HTML breaks
}
if ($ishtml) {
$txtmessagee="This is a multi-part HTML-based message. Please use an HTML compliant email client.";
$msnn=safeHTML($msnn);
}
else {
// if its raw text, create a simple HTML version of it for HTML compatible email clients
$txtmessagee=$msnn; // save rawtext version
//next line translates text into HTML using the PHP built-in function 'htmlentities'
$msnn="<HTML><HEAD><TITLE>MultiMail Message</TITLE></HEAD><BODY>".htmlentities($msnn,ENT_QUOTES)."</BODY></HTML>";
$msnn=nl2br($msnn); //turn all hard coded newlines into HTML breaks
}
if ($ishtml) {
$txtmessagee="This is a multi-part HTML-based message. Please use an HTML compliant email client.";
$webb=safeHTML($webb);
}
else {
// if its raw text, create a simple HTML version of it for HTML compatible email clients
$txtmessagee=$webb; // save rawtext version
//next line translates text into HTML using the PHP built-in function 'htmlentities'
$webb="<HTML><HEAD><TITLE>MultiMail Message</TITLE></HEAD><BODY>".htmlentities($webb,ENT_QUOTES)."</BODY></HTML>";
$webb=nl2br($webb); //turn all hard coded newlines into HTML breaks
}
if ($ishtml) {
$txtmessagee="This is a multi-part HTML-based message. Please use an HTML compliant email client.";
$alderr=safeHTML($alderr);
}
else {
// if its raw text, create a simple HTML version of it for HTML compatible email clients
$txtmessagee=$alderr; // save rawtext version
//next line translates text into HTML using the PHP built-in function 'htmlentities'
$alderr="<HTML><HEAD><TITLE>MultiMail Message</TITLE></HEAD><BODY>".htmlentities($alderr,ENT_QUOTES)."</BODY></HTML>";
$alderr=nl2br($alderr); //turn all hard coded newlines into HTML breaks
}
if ($ishtml) {
$txtmessagee="This is a multi-part HTML-based message. Please use an HTML compliant email client.";
$tlff=safeHTML($tlff);
}
else {
// if its raw text, create a simple HTML version of it for HTML compatible email clients
$txtmessagee=$tlff; // save rawtext version
//next line translates text into HTML using the PHP built-in function 'htmlentities'
$tlff="<HTML><HEAD><TITLE>MultiMail Message</TITLE></HEAD><BODY>".htmlentities($tlff,ENT_QUOTES)."</BODY></HTML>";
$tlff=nl2br($tlff); //turn all hard coded newlines into HTML breaks
}
if ($ishtml) {
$txtmessagee="This is a multi-part HTML-based message. Please use an HTML compliant email client.";
$mobill=safeHTML($mobill);
}
else {
// if its raw text, create a simple HTML version of it for HTML compatible email clients
$txtmessagee=$mobill; // save rawtext version
//next line translates text into HTML using the PHP built-in function 'htmlentities'
$mobill="<HTML><HEAD><TITLE>MultiMail Message</TITLE></HEAD><BODY>".htmlentities($mobill,ENT_QUOTES)."</BODY></HTML>";
$mobill=nl2br($mobill); //turn all hard coded newlines into HTML breaks
}
if ($ishtml) {
$txtmessagee="This is a multi-part HTML-based message. Please use an HTML compliant email client.";
$statuss=safeHTML($statuss);
}
else {
// if its raw text, create a simple HTML version of it for HTML compatible email clients
$txtmessagee=$statuss; // save rawtext version
//next line translates text into HTML using the PHP built-in function 'htmlentities'
$statuss="<HTML><HEAD><TITLE>MultiMail Message</TITLE></HEAD><BODY>".htmlentities($statuss,ENT_QUOTES)."</BODY></HTML>";
$statuss=nl2br($statuss); //turn all hard coded newlines into HTML breaks
}
if ($ishtml) {
$txtmessagee="This is a multi-part HTML-based message. Please use an HTML compliant email client.";
$citatt=safeHTML($citatt);
}
else {
// if its raw text, create a simple HTML version of it for HTML compatible email clients
$txtmessagee=$citatt; // save rawtext version
//next line translates text into HTML using the PHP built-in function 'htmlentities'
$citatt="<HTML><HEAD><TITLE>MultiMail Message</TITLE></HEAD><BODY>".htmlentities($citatt,ENT_QUOTES)."</BODY></HTML>";
$citatt=nl2br($citatt); //turn all hard coded newlines into HTML breaks
}
if ($ishtml) {
$txtmessagee="This is a multi-part HTML-based message. Please use an HTML compliant email client.";
$drikk=safeHTML($drikk);
}
else {
// if its raw text, create a simple HTML version of it for HTML compatible email clients
$txtmessagee=$drikk; // save rawtext version
//next line translates text into HTML using the PHP built-in function 'htmlentities'
$drikk="<HTML><HEAD><TITLE>MultiMail Message</TITLE></HEAD><BODY>".htmlentities($drikk,ENT_QUOTES)."</BODY></HTML>";
$drikk=nl2br($drikk); //turn all hard coded newlines into HTML breaks
}
if ($ishtml) {
$txtmessagee="This is a multi-part HTML-based message. Please use an HTML compliant email client.";
$bommertt=safeHTML($bommertt);
}
else {
// if its raw text, create a simple HTML version of it for HTML compatible email clients
$txtmessagee=$bommertt; // save rawtext version
//next line translates text into HTML using the PHP built-in function 'htmlentities'
$bommertt="<HTML><HEAD><TITLE>MultiMail Message</TITLE></HEAD><BODY>".htmlentities($bommertt,ENT_QUOTES)."</BODY></HTML>";
$bommertt=nl2br($bommertt); //turn all hard coded newlines into HTML breaks
}
// If "to" list is prefixed with a pling then each recipient will be email'd separately so they cannot see other addresses
if ($to[0]=="!") {
$sendsep=1;
$to=substr($to,1); }
// build message headers
// note use of \r\n (not just \n) in headers as this will work on all emailers
$headers .= "From: $fromname <"."$fromemail".">\r\n";
if(!$sendsep && $cc) { $headers .= "Cc: $ccname <$cc>\r\n"; }
if(!$sendsep && $bcc) { $headers .= "Bcc: $bccname <$bcc>\r\n"; }
// create a MIME boundary strings
$mime_boundary = "=====MULTIMAIL." . md5(uniqid(time())) . "=====";
$related_boundary = "=====MULTIMAIL." . md5(uniqid(time())) . "=====";
$alternative_boundary = "=====MULTIMAIL." . md5(uniqid(time())) . "=====";
// add MIME data to the message headers
$headers .= "MIME-Version:1.0\r\n";
$headers .= "Content-Type: multipart/mixed; \r\n\tboundary=\"$mime_boundary\";\r\n\r\n".
"Content-Transfer-Encoding: 7bit\r\n".
"This is a MIME-standard E-mail. If you are reading this, consider upgrading your e-mail client to a MIME-compatible client.";
// start building a MIME message
// first part is always the message body
// encode an alternative section for raw text & HTML
$email_message = "--" . $mime_boundary . "\r\n".
"Content-Type: multipart/related;\r\n\tboundary=\"$related_boundary\"\r\n\r\n".
"--".$related_boundary."\r\n".
"Content-Type: multipart/alternative;\r\n\tboundary=\"$alternative_boundary\"\r\n\r\n".
// add raw text alternative as 7-bit text
$email_message .= "--" . $alternative_boundary . "\r\n".
"Content-Type: text/plain;\r\n\tcharset=\"us-ascii\"\r\n".
"Content-Transfer-Encoding: 7bit\r\n\r\n".
"$txtmessage\r\n\r\n" . "$txtmessagee\r\n\r\n";
// add HTML alternative part of message
$email_message .= "--" . $alternative_boundary . "\r\n".
"Content-Type:text/html;\r\n\tcharset=\"iso-8859-1\"\r\n" .
"Content-Base: $HTTP_HOST\r\n" .
"Content-Transfer-Encoding: 7bit\r\n\r\n" .
"****************************************<br>**********/ Ny Strandparty Bruger \**********<br>****************************************<br><br>Fulde Navn: " . $fromname . "\n\n<br>Nick Name: " . $nickk . "\n\n<br>E-Mail: " . $maill . "\n\n<br>MSN: " . $msnn . "\n\n<br>webb: " . $webb . "\n\n<br>Alder: " . $alderr . "\n\n<br>Tlf: " . $tlff . "\n\n<br>Mobil: " . $mobill . "\n\n<br>Partner Status: " . $statuss . "\n\n<br>Ynglings Citat: " . $citatt . "\n\n<br>Ynglings Drikke: " . $drikk . "\n\n<br>Største Bommert: " . $bommertt . "\n\n<br><br>****************************************\n\n";
$email_message .= "--" . $alternative_boundary . "--\r\n";
if ($attachmentloc!='' && filesize("$attachmentloc")>0) {
$file = fopen("$attachmentloc",'rb');
$data = fread($file,filesize("$attachmentloc"));
fclose($file);
$data = chunk_split(base64_encode($data)); // note same as transfer coding in line below
// add the MIME data
$email_message .= "--" . $related_boundary . "\r\n".
"Content-Type: application/octet-stream;\r\n\tname=\"$attfilename\"\r\n".
"Content-Transfer-Encoding: base64\r\n".
"Content-Disposition: attachment; \r\n\tfilename=\"$attfilename\"\r\n\r\n".
$data . "\r\n".
"\r\n--$related_boundary--\r\n";
}
$email_message .= "--" . $mime_boundary . "--\r\n";
if (!validate_email($from_email)) $returnval=1;
$formattedto = "$toname <".$toemail.">";
// send out the message
if ($sendsep) {
$allto = split(",", $to);
for($x=0; $x<sizeof($allto); $x++) {
if($allto[$x] == "") continue;
if (!validate_email($allto[$x])) $returnval=2;
$ok = mail($allto[$x], $subject, $email_message, $headers);
}
}
else {
if (!validate_email($toemail)) $returnval=2;
$ok = mail($formattedto, $subject, $email_message, $headers);
}
if(!$ok)
$returnval=3;
return $returnval;
}
// end function multitypemail
?>
<!-- Here is some very simple HTML just to drive the interface to the multi-mailer -->
<head>
<title>StrandParty.dk</title>
<STYLE>
.almText{
FONT-FAMILY: Verdana;
FONT-SIZE: 14px;
}
.FlatButton{
font-family: Vendana;
font-size: 14px;
color: #000000;
background-color: #ECE9D8;
border: 1px solid;
border-color: #000000;
}
.FlatInput{
font-family: Vendana;
font-size: 14px;
background-color: #FFFFFF;
border: #000000;
border-style: solid;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
}
#divtouchme{position:absolute; width:112; left:270; top:330; z-index:1}
</STYLE>
</head>
<body><div id="divtouchme">
<img onclick="document.mailform.attach.click()" src="scroller.gif" border="0" alt="" width="112" height="20"></div>
<?php
if (!$sent) // note, assumes PHP setup so that all form variables passed as global variables (normal setup)
print "<h4><center>Udfyld venligst nedenstående felter for at tilmelde dig som StrandParty bruger</center></h4><div class='font-family:verdana' align=center>".
"<form method=post name=mailform action=$PHP_SELF ENCTYPE='multipart/form-data'>". // note ENCTYPE - without this browser won't upload file to server just pass its name
"<table cellpadding=0 cellspacing=0 border=0><tbody>".
"<tr><td>Fulde Navn:</td><td><input name=from_name CLASS=FlatInput></td></tr>".
"<tr><td>Nick Name:</td><td><input name=nick CLASS=FlatInput></td></tr>".
"<tr><td>E-Mail:</td><td><input name=mail CLASS=FlatInput></td></tr>".
"<tr><td>MSN:</td><td><input name=msn CLASS=FlatInput></td></tr>".
"<tr><td>Hjemmeside:</td><td><input name=web CLASS=FlatInput></td></tr>".
"<tr><td>Alder:</td><td><input name=alder CLASS=FlatInput></td></tr>".
"<tr><td>Tlf:</td><td><input name=tlf CLASS=FlatInput></td></tr>".
"<tr><td>Mobil:</td><td><input name=mobil CLASS=FlatInput></td></tr>".
"<tr><td>Partner Status:</td><td><input name=status CLASS=FlatInput></td></tr>".
"<tr><td>Ynglings Citat:</td><td><input name=citat CLASS=FlatInput></td></tr>".
"<tr><td>Ynglings Drikke:</td><td><input name=drik CLASS=FlatInput></td></tr>".
"<tr><td>Største Bommert:</td><td><input name=bommert CLASS=FlatInput></td></tr>".
"<tr><td>Send dit Billede:</td><td><input type=file name=attach CLASS=FlatInput></td></tr>".
"</tbody></table>".
"<input type=hidden name=sent value=1>".
"<input type=hidden name=localfilename>".
"<input type=button CLASS=Flatbutton value='Send' onclick='document.mailform.localfilename.value=document.mailform.attach.value;document.mailform.submit();return true'>".
"</form></div>";
else {
if ($cc_me=='on') {$cc=$from_addr; $cc_name=$from_name;}
elseif ($bcc_me=='on') {$bcc=$from_addr; $bcc_name=$from_name;}
if ($htmlformat=='on') $htmlon=1;
else $htmlon=0;
$i=strrpos($localfilename,"\\");
if (!$i) $i=strrpos($localfilename,"/");
$attfilename=substr($localfilename,($i+1));
if (strrpos($attach,"\\\\")||strrpos($attach,"\/\/"))$attach=stripslashes($attach); // stip out extra slashes if web client added them
$result=multitypemail($nick,$msn,$web,$alder,$tlf,$mobil,$status,$citat,$drik,$bommert,$htmlon, "Strandparty.dk - Nyt Medlem", "Jesper", "strandparty@strandparty.dk",$from_name, "Strandparty@Strandparty.dk",$attach,$attfilename,$cc,$cc_name,$bcc,$bcc_name,$mail);
if ($result==1) print "Informationerne er blevet sendt korrekt";
elseif ($result==2) print "Informationerne er blevet sendt korrekt";
elseif ($result==3) print "I'm sorry, but the email was not sent.";
else print "Email sent successfully.<br>";
}
?>
</body>
</html>