nastavenie sendemail.php

Programovacie jazyky, rady, poradňa...
luksiman
Light Star
Light Star
Používateľov profilový obrázok
Príspevky: 221
Registrovaný: 21 nov 2006, 14:28

nastavenie sendemail.php

Príspevok od používateľa luksiman »

Caute prosim vas, mam stranku (prerobeny template) a v stranke kontakt kde sa nachadza kontaktny formular po vpylneni a odosslani mi neprijde mail tam kam ma viete mi pomoct? mam tam subor sendmail.php a neviem ho nastavit.. dakujem

Kód: Vybrať všetko

<?php


// Change this with your blog name and email address
$the_blogname   = '';
$the_myemail 	= '';


if(isset($_POST['email'])){
		error_reporting(0);	
		$errorC = false;

		$the_email 		= $_POST[''];
		$the_name 		= $_POST['yourname'];
		$the_message 	= $_POST['message'];

		$the_phone 		= $_POST['phone'];
		$the_fax 		= $_POST['fax'];
		$the_company 	= $_POST['company'];
		$the_website 	= $_POST['website'];
		
		# want to add aditional fields? just add them to the form in template_contact.php,
		# you dont have to edit this file
		
		//added fields that are not set explicit like the once above are combined and added before the actual message
		$already_used = array('email','yourname','message','phone','fax','company','website','myblogname','tempcode','temp_url','ajax');
		$attach = '';
		
		foreach ($_POST as $key => $field)
		{
			if(!in_array($key,$already_used))
			{
				$attach.= $key.": ".$field."<br /> \n";
			}
		}
		$attach.= "<br /> \n";
		
		if(!checkmymail($the_email))
		{
			$errorC = true;
			$the_emailclass = "error";
		}else{
			$the_emailclass = "valid";
			}
		
		if($the_message == "")
		{
			$errorC = true;
			$the_messageclass = "error";
		}else{
			$the_messageclass = "valid";
			}
		
		if($errorC == false)
		{ 	
			$to      =  $the_myemail;
			$subject = "New Message from " . $the_blogname;
			$header  = 'MIME-Version: 1.0' . "\r\n";
			$header .= 'Content-type: text/html; charset=utf-8' . "\r\n";
			$header .= 'From:'. $the_email  . " \r\n";
		
			$message1 = nl2br($the_message);

			if(!empty($the_name)) 		$the_name 		= "Name:  	$the_name <br/>";
			if(!empty($the_company)) 	$the_company 	= "Company: $the_company <br/>";
			if(!empty($the_phone)) 		$the_phone 		= "Phone:   $the_phone <br/>";
			if(!empty($the_fax)) 		$the_fax 		= "Fax:  	$the_fax <br/>";
			if(!empty($the_website)) 	$the_website 	= "Website: $the_website <br/>";
			
			$message = "
			You have a new message! <br/>
			$the_name
			$the_company
			$the_phone
			$the_website
			
			$attach <br />
			
			Message: $message1 <br />";
			
		
			
			if(@mail($to,$subject,$message,$header)) $send = true; else $send = false;
			
			if(isset($_POST['ajax'])){
				
			if ($send)
			echo '<h3>Vaša správa bola odoslaná!</h3><div class="potvrdiť">
					<p class="textconfirm">Ďakujeme Vám za vášu navštevu<br/>Radi Vás uvidíme čo najskôr.</p>
				  </div>';
			else
			echo '<h3>Oops!</h3><div class="confirm">
					<p class="texterror">Chyba skúste neskôr alebo nás kontaktujte priamo na adresu [email protected]</p>
				  </div>'; 
				
			}
		}
		
}
	
	
function checkmymail($mailadresse){
	$email_flag=preg_match("!^\w[\w|\.|\-]+@\w[\w|\.|\-]+\.[a-zA-Z]{2,4}$!",$mailadresse);
	return $email_flag;
}

?>
Ovecka
Darca
Darca
Používateľov profilový obrázok
Príspevky: 1227
Registrovaný: 25 aug 2005, 0:57

Re: nastavenie sendemail.php

Príspevok od používateľa Ovecka »

$the_blogname = 'Nazov tvojej stranky';
$the_myemail = 'tvoj email';
#----------------

ps: nepouzivaj funkciu mail
luksiman
Light Star
Light Star
Používateľov profilový obrázok
Príspevky: 221
Registrovaný: 21 nov 2006, 14:28

Re: nastavenie sendemail.php

Príspevok od používateľa luksiman »

ShepDog napísal:$the_blogname = 'Nazov tvojej stranky';
$the_myemail = 'tvoj email';
#----------------

ps: nepouzivaj funkciu mail

lenze ked tam dam email adress na ktoru maju chodit z contactformu tak mi nepride, why?
teleport
Expert
Expert
Používateľov profilový obrázok
Príspevky: 167
Registrovaný: 01 aug 2012, 16:06
Bydlisko: Bratislava

Re: nastavenie sendemail.php

Príspevok od používateľa teleport »

lebo tam mas chybu:

Kód: Vybrať všetko

$the_email       = $_POST[''];
luksiman
Light Star
Light Star
Používateľov profilový obrázok
Príspevky: 221
Registrovaný: 21 nov 2006, 14:28

Re: nastavenie sendemail.php

Príspevok od používateľa luksiman »

teleport napísal:lebo tam mas chybu:

Kód: Vybrať všetko

$the_email       = $_POST[''];
mohol by si byt kontkretnejsi? co tam presne ma byt?
audiotrack
VIP
VIP
Používateľov profilový obrázok
Príspevky: 25958
Registrovaný: 09 sep 2005, 18:39
Kontaktovať používateľa:

Re: nastavenie sendemail.php

Príspevok od používateľa audiotrack »

medzi tými apostformi ti chýba názov elementu z formuláru, do ktorého sa vpisuje email. Podobne ako pre ostatné prvky pod tým kde to vyplnené máš
dykeer
Medium Expert
Medium Expert
Používateľov profilový obrázok
Príspevky: 102
Registrovaný: 02 jan 2011, 21:21
Kontaktovať používateľa:

Re: nastavenie sendemail.php

Príspevok od používateľa dykeer »

A nezabudaj, ze hostingy maju bezpecnostne nastavenie, ze mail odoslu len ak je priradeny k hostingu... teda $the_email nemozes naplnat z formularu, lebo tam si user vyplni mail, ktory zjavne nie je z domeny, kde skript bezi.
Napísať odpoveď