Kontaktformular: Kopie an Absender mit zusätzlicher Infomation möglich?

arraybreak

Erfahrenes Mitglied
Tag zusammen,

ich würde gern eine zusätzliche Informationen bzw. zusätzlichen Text an Absender in gleicher E-Mail mitschicken wollen, die nur er bekommt und nicht der Empfänger, ist es möglich?

Beispiel:
Empfänger:
Nachname, Name, Strasse etc.

Absender bekommt als Kopie:
Nachnahme, Name, Strasse etc. + zusätzliches Text wie z.b. "Danke ..."

Ist es möglich?

Hier nochmal mit Quellcode:
PHP:
<?php

date_default_timezone_set('Europe/Berlin');

// User settings
$to = "meineemail@meineseite.de";
$subject = stripslashes(utf8_decode("Anfrage über Meine Seite"));

// Include extra form fields and/or submitter data?
// false = do not include
$extra = array(
	"form_subject"	=> false,
	"form_cc"		=> true,
	"ip"			=> false,
	"user_agent"	=> false
);

// Process
$action = isset($_POST["action"]) ? $_POST["action"] : "";
if (empty($action)) {
	// Send back the contact form HTML
	$output = "<div style='display:none'>
	<div class='contact-top'><h7>Anfrage über Meine Seite</h7></div>
	<div class='contact-content'>
	<div id='wrapper'>

		<div class='contact-loading' style='display:none'></div>
		<div style='margin-top:20px; text-align:center;'><h3 class='contact-title'></h3></div>
		<div class='contact-message' style='display:none'></div>
              <div id='steps'>
				<form id='formElem' name='formElem' action='#' style='display:none'>
                   
                        <fieldset class='step'>
                            <legend>Formular</legend>
							<p style='width:420px'>
                                <label for='contact-firma'>Firma</label>
                                <input style='width:310px' type='text' id='contact-firma' name='firma' />
                            </p>
							<p style='width:200px'>
							  <label for='contact-anrede'>Anrede</label>
                                <select style='width:80px; height:26px' id='contact-anrede' name='anrede'>
                                    <option>&nbsp;</option>
                                    <option>Herr</option>
                                    <option>Frau</option>
                                </select>
                            </p>
                            <p>
                                <label for='contact-name'>Nachname</label>
                                <input type='text' id='contact-nachname' name='nachname' />
                            </p>
							<p>
                                <label for='contact-vorname'>Vorname</label>
                                <input id='contact-vorname' name='vorname' />
                            </p>
							<p style='width:652px'>
                                <label for='contact-strasse'>Sraße + Nr.</label>
                                <input style='width:542px' id='contact-strasse' name='strasse' />
                            </p>
							<p>
                                <label for='contact-plz'>PLZ</label>
                                <input id='contact-plz' name='plz' />
                            </p>
							<p>
                                <label for='contact-ort'>Ort</label>
                                <input id='contact-ort' name='ort' />
                            </p>
							<p>
                                <label for='contact-gb'>Geburtsdatum</label>
                                <input id='contact-gb' name='gb' placeholder='oder Gründungsjahr'/>
                            </p>
							<p>
                                <label for='contact-telefon'>Telefonnummer</label>
                                <input id='contact-telefon' name='telefon' />
                            </p>
							<p>
                                <label for='contact-beruf'>Beruf</label>
                                <input id='contact-beruf' name='beruf' />
                            </p>
                            <p>
                                <label for='contact-email'>Email</label>
                                <input id='contact-email' name='email' placeholder='ihre@email.de' type='email' />
                            </p>
                        </fieldset>				
						<fieldset class='step'>
                            <legend>Absenden</legend>";
	$output .= "		
			<p style='width:652px'><input style='width:100px; margin:15px 0' checked='checked' type='checkbox' id='contact-ds' name='contact-ds' value='JA'/><span  class='contact-cc'>Ich/wir gebe/n unser ausdrückliches Einverständnis...</span></p>";						
							
	if ($extra["form_cc"]) {
		$output .= "
			<p style='width:652px'><input style='width:100px; margin:15px 0' type='checkbox' id='contact-cc' name='cc' value='1'/><span class='contact-cc'></br>Eine Kopie an mich</span></p>
			<br/>";
	}

	$output .= "
			<p style='text-align:center'>
			<button type='submit' class='contact-send'>Absenden</button></p>
			<p style='text-align:center'><button type='submit' class='contact-cancel simplemodal-close' >Abbrechen</button>
			<br/>
			<input type='hidden' name='token' value='" . smcf_token($to) . "'/>
			</p>
                        </fieldset>
                    </form>
               </div>               
            </div>
            </div>
		
		";

	echo $output;
}
else if ($action == "send") {
	// Send the email
	$name = isset($_POST["name"]) ? $_POST["name"] : "";
	$email = isset($_POST["email"]) ? $_POST["email"] : "";
	$subject = isset($_POST["subject"]) ? $_POST["subject"] : $subject;
	$message = @$_POST['message'] . "\r\n\r\n";

	$message .= 'Formular:' . @$_POST[''] . "\r\n";
	$message .= '-------------------------------------------------' . @$_POST[''] . "\r\n";
	$message .= 'Firma: ' . @$_POST['firma'] . "\r\n";
	$message .= 'Anrede: ' . @$_POST['anrede'] . "\r\n";
	$message .= 'Nachname: ' . @$_POST['nachname'] . "\r\n";
	$message .= 'Vorname: ' . @$_POST['vorname'] . "\r\n";
	$message .= 'Strasse: ' . @$_POST['strasse'] . "\r\n";
	$message .= 'PLZ: ' . @$_POST['plz'] . "\r\n";
	$message .= 'Ort: ' . @$_POST['ort'] . "\r\n";
	$message .= 'Geburtsdatum: ' . @$_POST['gb'] . "\r\n";
	$message .= 'Telefon: ' . @$_POST['telefon'] . "\r\n";
	$message .= 'Beruf: ' . @$_POST['beruf'] . "\r\n";
	$message .= 'E-Mail: ' . @$_POST['email'] . "\r\n\r\n";

	$message .= '-------------------------------------------------' . @$_POST[''] . "\r\n";		
	$message .= 'Bedingungen akzeptiert: ' . @$_POST['contact-ds'] . "\r\n\r\n";
	
	$cc = isset($_POST["cc"]) ? $_POST["cc"] : "";
	$token = isset($_POST["token"]) ? $_POST["token"] : "";

	// make sure the token matches
	if ($token === smcf_token($to)) {
		smcf_send($name, $email, $subject, $message, $cc);
		echo "Ihre Nachricht wurde erfolgreich &uuml;bermittelt.";
	}
	else {
		echo "Leider konnte Ihre Nachricht nicht zugestellt werden.";
	}
}

function smcf_token($s) {
	return md5("smcf-" . $s . date("WY"));
}

// Validate and send email
function smcf_send($name, $email, $subject, $message, $cc) {
	global $to, $extra;

	// Filter and validate fields
	$name = smcf_filter($name);
	$subject = smcf_filter($subject);
	$email = smcf_filter($email);
	if (!smcf_validate_email($email)) {
		$subject .= " - invalid email";
		$message .= "\n\nBad email: $email";
		$email = $to;
		$cc = 0; // do not CC "sender"
	}

	// Add additional info to the message
	if ($extra["ip"]) {
		$message .= "\n\nIP: " . $_SERVER["REMOTE_ADDR"];
	}
	if ($extra["user_agent"]) {
		$message .= "\n\nUSER AGENT: " . $_SERVER["HTTP_USER_AGENT"];
	}

	// Set and wordwrap message body
	$body = "";
	$body .= "$message";
	$body = wordwrap($body, 70);

	// Build header
	$headers = "From: $email\n";
	if ($cc == 1) {
		$headers .= "Cc: $email\n";
	}
	$headers .= "X-Mailer: PHP/SimpleModalContactForm";

	// UTF-8
	if (function_exists('mb_encode_mimeheader')) {
		$subject = mb_encode_mimeheader($subject, "UTF-8", "B", "\n");
	}
	else {
		// you need to enable mb_encode_mimeheader or risk 
		// getting emails that are not UTF-8 encoded
	}
	$headers .= "MIME-Version: 1.0\n";
	$headers .= "Content-type: text/plain; charset=utf-8\n";
	$headers .= "Content-Transfer-Encoding: quoted-printable\n";

	// Send email
	@mail($to, $subject, $body, $headers) or 
		die("Leider verhinderte ein Server-Problem Zustellung Ihrer Nachricht.");
}

// Remove any un-safe values to prevent email injection
function smcf_filter($value) {
	$pattern = array("/\n/","/\r/","/content-type:/i","/to:/i", "/from:/i", "/cc:/i");
	$value = preg_replace($pattern, "", $value);
	return $value;
}

// Validate email address format in case client-side validation "fails"
function smcf_validate_email($email) {
	$at = strrpos($email, "@");

	// Make sure the at (@) sybmol exists and  
	// it is not the first or last character
	if ($at && ($at < 1 || ($at + 1) == strlen($email)))
		return false;

	// Make sure there aren't multiple periods together
	if (preg_match("/(\.{2,})/", $email))
		return false;

	// Break up the local and domain portions
	$local = substr($email, 0, $at);
	$domain = substr($email, $at + 1);


	// Check lengths
	$locLen = strlen($local);
	$domLen = strlen($domain);
	if ($locLen < 1 || $locLen > 64 || $domLen < 4 || $domLen > 255)
		return false;

	// Make sure local and domain don't start with or end with a period
	if (preg_match("/(^\.|\.$)/", $local) || preg_match("/(^\.|\.$)/", $domain))
		return false;

	// Check for quoted-string addresses
	// Since almost anything is allowed in a quoted-string address,
	// we're just going to let them go through
	if (!preg_match('/^"(.+)"$/', $local)) {
		// It's a dot-string address...check for valid characters
		if (!preg_match('/^[-a-zA-Z0-9!#$%*\/?|^{}`~&\'+=_\.]*$/', $local))
			return false;
	}

	// Make sure domain contains only valid characters and at least one period
	if (!preg_match("/^[-a-zA-Z0-9\.]*$/", $domain) || !strpos($domain, "."))
		return false;	

	return true;
}

exit;

?>
 
Entweder verscuhen zu verstehen was in dem Code wie läuft und dann selber probieren, oder einen Auftrag ins Job-Forum setzen.
 
Versuch deinen "kopierten" Code zu verstehen.. Sonst bringt es dir nichts wenn wir dir auch nur einen Code geben um 2 Mails zu schicken..
 
Wie meisti94 schreibt.
Beginne ganz oben den Code zu lesen. Befehle die du nicht kennst in der PHP-Doku nachschlagen.
Wenn du das ganze schon nicht verstehst hat es keinen Zweck wenn wir dir erklären wie die Mailbefehle funktionieren. Das währe als ob wir dir deutsche Rechtschreibung beibringen und du kein Wort deutsch kannst.
 
Zurück