Помощ за един скрипт за изпращане на e-mail

maxaffey

Registered
Имам един много готин скрипт, който бачка без грешка,но ми трябва да добавя още една функция към него!

Става въпрос, че скрипта изпраща данните на дадени е-мейли, но аз искам да се селектират и друг тип данни и да ги изпраща на е-мейла на подателя!

Примерно: Благодарим ви г-н....... получихме вашите данни, и този е-мейл да се изпраща на дадения от него личен майл.

Ето и скриптовете:

Първо от този скрипт изпращам данните:

Код:
<html><head><title>Contact form</title>
<style>p{font:10pt ms sans serif;}</style>
</head><body>
<center><h1>Contact form</h1>
<br><br>

<form action="files/dataProcess.php" method=post>
<table align=center border=0 height=400>
<tr> 
<td nowrap> 
<p>    Your name:  
  <input maxlength=25 name=name size=45>
</td></tr> 
<tr> 
<td nowrap> 
<p>    Your email:  
  <input name=from size=45 maxlength=50>
</td></tr>
<tr>
<td colspan=2>
<center>
<p align=center>Enter your message below:
<br>
<textarea cols=50 name=message rows=12></textarea>
<p align=center>
<input type=submit value="Send Mail">
<input type=reset value=Reset name="reset">
</td></tr></table>
</form>
</center>
</body></html>



От този скрипт се изпращат данните, по мои зададени параметри и кои данни как да ми ги изпрати.

Код:
<?php	
include('../config.php');
$name = $_POST['name']; $from = $_POST['from']; $message = $_POST['message'];
$register_globals = (bool) ini_get('register_gobals');
if ($register_globals) { $ip=getenv(REMOTE_ADDR); } 
else $ip=$_SERVER['REMOTE_ADDR'];
if($verify_referrer=="1")
	if(!eregi("$domain", $HTTP_REFERER) && !eregi("$domainAlias", $HTTP_REFERER)) 
        {
                $error=1;

                if($ipLogging=="1"){ 
		 	$date=date ("l dS of F Y h:i:s A");
			$ipLog="ipLog.htm";
			$fp=fopen("$ipLog", "a+");
			fputs($fp, "<font face=arial size=3>  >>> Logged IP address: $ip - Date: $date<br>");
			fclose($fp);

			$errorMesB="ERROR: Invalid domain.<br><br><b>NOTICE:</b> Your IP has been logged as: $ip."; $error=1;
		}
		else{ $errorMesA="ERROR: Invalid domain."; $error=1; }
		if($notify=="1"){
       			$subject=$notifySubject;
        		if($HTMLmailFormat=="1"){
				$body=" <font face=arial size=3><br>
        				--------<font color=red>WARNING!</font><font face=arial size=3> Form abuse notification ------
        				<br><br><br><font face=arial size=2>A person has attempted to abuse the contact form.
        				<br><font face=arial size=2>Their IP address was logged as: $ip <br></font><br>";
                        }
                        else{
                              	$body=" \n--------WARNING! Form abuse notification ------\n\n\n
        				A person has attempted to abuse the contact form.\n
        				Their IP address was logged as: $ip \n";
                        }
			$from=$notifyFrom;
			if($HTMLmailFormat=="1") $headers="Content-Type: text/html; charset=windows-1252 \n";
                        else $headers="Content-Type: text/plain \n";
			$headers.="From: $from \n";
			$headers.="X-mailer: \"contactMe\" published at www.digi-dl.com \n";

			mail($to,$subject,$body,$headers);

                        $errorMesC="An email with this information has been sent to the webmaster."; $error=1;
		}
   	} 
}

$name=trim($name); $name = preg_replace("/>/","]",$name); $name = preg_replace("/</","[",$name);

// If user enters NO name
if($ime==""){ $errorMes1="??????: ?? ??? ???????? ?????. "; $error=1; }

// Trim whitespace from user input 
$message=trim($message); if($message==""){ $errorMes2="ERROR: You didn't write a message. "; $error=1; }

// If all is well so far there are no errors
else
	$error=0;

// If there IS data in the email field then check it
if ($from!==""){

        // Check email address for certain charcters
	if (!eregi("^.+@.+\\..+$", $from)) 
	{ 
		$errorMes4="??????: ?? ??? ?????? ???????? ?-????. "; $error=1; 
	}

        // If email address pass check then trim whitespace
        else
		$from=trim($from);
}
else { $errorMes5="ERROR: You need to enter an email address. "; $error=1; }

if ($error=="1"){
	echo ("<title>SendMail Error</title>
        <body><br>
	<p style=\"font:11pt arial\">SendMail <font color=red> Error</font>
	<br><br>The following errors have occured:<br><br>
	$errorMes1<br>$errorMes2<br>$errorMes3<br>$errorMes4<br>$errorMes5<br>$errorMesA<br>$errorMesB<br>$errorMesC<br>
	<br><a href=\"../contactMe.htm\" style=\"color:black\">Click here</a> to try again. </body></html>"); exit(0);
}

else if ($error=="0"){

        if($HTMLmailFormat=="1") {
		$message = preg_replace("/>/",">",$message); $message = preg_replace("/</","<",$message);

		$body="<font face=arial size=2>$message</font <br><br><br>
                       <font face=\"ms sans serif\" size=2>
                       --------------- SENDER INFORMATION ------------
               	       <br>This message was sent to you by $name.<br>
               	       $name's email address is: $from<br>
               	       $name's IP address is: $ip </font><br>";
        }
       
        else{
		$body="$message\n\n\n
                       --------------- SENDER INFORMATION ------------
		       \nThis message was sent to you by $name.\n
               	       $name's email address is: $from\n
               	       $name's IP address is: $ip \n";
        }
	$from="\"$name\" <$from>";

        // Set headers based on content type (plain / HTML)
        if($HTMLmailFormat=="1") $headers="Content-Type: text/html; charset=windows-1252\n";
        else $headers="Content-Type: text/plain \n";
	$headers.="From: $from \n";
        $headers.="X-mailer: \"contactMe\" published at www.digi-dl.com \n";

        // Send mail
	mail($to,$subject,$body,$headers);

        // display mail sent message
        echo (" <title>SendMail Notice: mail was successfully sent</title><body><br><br><br><br>
		<p style=\"font:11pt arial\" align=center>Your mail has been successfully sent...<i>Thank you</i></p>
		</body></html>"); exit(0);

// exit script
} exit(0);
?>





А от този скрипт взима данните на кой е-мейл да го изпрати, какви данни и т.н.

Код:
<?php

// PHP script by Dave Lauderdale 
// Published at: www.digi-dl.com
// ENTER YOUR INFORMATION BELOW


$maxSize="500";                            // Maximum size of the letters message
$subject="visitor comments";               // The subject line of the letters that you receive
$to="novini@novini.bg";                     // The email address you want letters sent to

$HTMLmailFormat="1";                       // Do you want to use HTML mail (1 for yes and 0 for no)

$verify_referrer="1";	                   // Do you want to do domain checking (1 for yes and 0 for no)
$domain="http://yoursite.com";             // Enter your domain here if you want to verify it
$domainAlias="http://www.yoursite.com";    // Enter your domains alias here if you want to verify it

$ipLogging="1";                            // Do you want to do IP logging (1 for yes and 0 for no)
$notify="1";                               // Do you want to be notified when an IP is logged  (1 or 0)
$notifyFrom="formAbuse@yoursite.com";      // What do you want the notifications 'From' field to say
$notifySubject="Form abuse notification";  // What do you want the notifications 'Subject' line to say

?>
 
Код:
<?php 
$maxSize="500";  
                         
$subject="visitor comments";   
$to="novini@novini.bg";
                    
$HTMLmailFormat="1"; 
                   
$verify_referrer="1"; 
                 
$domain="http://yoursite.com";  

$domainAlias="http://www.yoursite.com";
    
$ipLogging="1";  

 $notify="1"; 

 $notifyFrom="formAbuse@yoursite.com"; 

$notifySubject= 'Благодарим ви г-н '.$name.' получихме вашите данни' ; 


?>

Това е .

МАхнал съм коментарите нарочно щото могат да направят проблем.
 
И още:

Разгледай този код.
Той ще ти разясни много неща.

Код:
<head> 
<title>Поща</title> 
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251"> 
</head> 
<?php 

$to = 'amd@abv.bg' . ', '; 



$subject = 'hosting'; 



$message = ' 
<html> 
<head> 
<title></title> 
</head> 
<body > 
host.bg предлага уеб хостинг.<br><br> 

1000MB пространство<br> 
50GB месечен трафик<br> 
500 email кутии <br> 
Email Anti Virus <br> 
Email Anti Spam <br> 
PHP, Perl и 15xMySQL <br> 
Eжедневен back-up <br> 
SSH достъп<br> 
11.75 лв./месец <br> 

За повече информация натиснете<a href="http://host.bg">  тук</a>.

</body> 
</html> 


'; 


$headers = 'MIME-Version: 1.0' . "\r\n"; 
$headers .= 'Content-type: text/html; charset=windows-1251' . "\r\n"; 



$headers .='From:admin@host.bg' . "\r\n" . 
'Reply-To:admin@host.bg' . "\r\n" . 
'X-Mailer: PHP/' . phpversion(); 



mail($to, $subject, $message, $headers); 

?> 
OK




$to = 'amd@abv.bg' . ', '; - получател
$subject = 'hosting'; - относно
$message = 'текст на писмото'; - текста може да е HTML код ( както е в случая)
From:admin@host.bg - от кой е пуснато ( каквото пишете тука такова ще му покаже на получателя.
Може да пишете че е от boikoborisov@mvr.bg ако искате. :)
Reply-To:admin@host.bg - На кой да върне отговора .
(Ако натисне бутона "Отговори" да му излезе пощата admin@host.bg)


Пращаш писмо което съдържа html код и той се изпълнява
когато човека си чете пощата.
По готино е .
Може да го изненадаш.
 
Всъщност мога да качвам други файлове, но сега имам друг проблем.Като копирам съдържанието в Wordpad или Notepad и не мога да го запаметч в .php формат мога само като текстов документ да го запаметя :(
 

Back
Горе