Hej,
jag har ett problem, mitt script skickar inte mailen ditt den ska. Jag vill att mailen ska gå till contact_emai som jag hämtar från databasen och till mig.
<?php
require_once( GLOBAL_ROOT . 'DB/Database.class.php' );
require_once( SMARTY_CLASS );
require_once( GLOBAL_ROOT . '_smarty.php');
require_once( GLOBAL_ROOT . '_db_start.php');
$object_id = $_GET[ 'object_id' ];
$contact_info = $dbObj->query( 'SELECT object.name AS object_name, object_type.name AS object_type_name, contact_firstname, contact_lastname, contact_email, contact_phone_1, contact_phone_2
FROM object
JOIN object_type ON object.object_type_id = object_type.object_type_id
WHERE object_id = ' . $object_id . ';' );
$smarty->assign( 'contact_info', $contact_info );
/**
* assign pagerelated info to fill in <title></title>
*/
$smarty->assign('title', 'Book now - Traveletto.com');
/**
* no mail is sent by default
*/
$smarty->assign( 'mail_sent', false );
/**
* send mail
*/
if( isset( $_GET[ 'send' ] )){
while ($row = mysql_fetch_assoc($contact_info)) {
$tmp_str= $row['object_id'];
}
$strName = $_POST[ 'txtName' ];
$strEmail = $_POST[ 'txtEmail' ];
$strTelephone = $_POST[ 'txtTelephone' ];
$strSubject = 'Traveletto.com - Inquiry regarding object ' . $contact_info[ 'object_name' ];
// Fix
$strLengtOfStay = $_POST[ 'lenght_of_stay' ];
$strNumberOfGuests = $_POST[ 'number_of_guests' ];
$strYear = $_POST[ 'year' ];
$strMonth = $_POST[ 'month' ];
$strDay = $_POST[ 'day' ];
// end of Fix
$strMessage = $_POST[ 'areaMessage' ];
if($strName == ""){
echo("
Must enter a name");
exit;
}
if($strEmail == "") {
$strEmail = "none";
}
if($_POST[ 'areaMessage' ] == ""){
echo("
Must enter a message");
exit;
}
$strMessage = "Name: ".$strName."\r\n";
$strMessage .= "Email: ".$strEmail."\r\n";
$strMessage .= "Length of stay: ".$strLengtOfStay."\r\n";
$strMessage .= "Number of Guests: ".$strNumberOfGuests."\r\n";
$strMessage .= "Date: ".$strDay."-".$strMonth."-".$strYear."\r\n\r\n";
$strMessage .= $_POST[ 'areaMessage' ];
$strHeaders = "MIME-Version: 1.0\r\n";
$strHeaders .= "Content-type: text/html; charset=iso-8859-1\r\n";
$strHeaders .= "From: " . $strName . "<". $strEmail . ">\r\n";
$strHeaders .= "Reply-To:" . $contact_email;
$strHeaders .= "Reply-To:
[email protected]";
$to_str=$contact_email. ' ,
[email protected] ';
if( mail( $to_str, $strSubject, $strMessage, $strHeaders ) ) {
$smarty->assign( 'mail_sent', true );
}
}
$smarty->display('book_now.tpl');
require_once( GLOBAL_ROOT . '_db_end.php');
?>