<?
Error_Reporting(E_ALL & ~E_NOTICE);
$message=' ';
require_once('PHPMailerAutoload.php');
$email = new PHPMailer();
//$email->isSMTP();
$email->Host = "ssl://ххххххх.ru";
$email->Port = 465;
$email->SMTPAuth = true;
$email->SMTPSecure = 'SSL/TLS';
$email->Username = "xxxxxx@xxxx.ru";
$email->Password = "xxxxxxxxxxx";
$email->CharSet = 'UTF-8';
$id=intval($_REQUEST['id']);
$email->addReplyTo($data['send_email'][1]=$rz_cont['email'],$data['contakt'][1]=$rz_cont['contakt']);
$email->From = 'xxxxxx@xxxxxxx.ru';
$email->FromName = 'Vasia';
$email->Body = $message;
$message = $_POST['message'];
if(isset($id))
{
$r=mysqli_query($link,"SELECT email FROM book WHERE id='".$id."'");
$row = mysqli_fetch_array($r,MYSQLI_ASSOC);
$email->AddAddress($row['email']); // Добавить получателя
}
if(isset($id))
{
$z_cont=mysqli_query($link,"SELECT contakt, email, tel FROM ark WHERE id_ark='".intval($_SESSION['ID_P'][1])."'");
$rz_cont=mysqli_fetch_array($z_cont);
$email->addReplyTo($data['send_email'][1]=$rz_cont['email'],$data['contakt'][1]=$rz_cont['contakt']);
$r=mysqli_query($link,"SELECT * FROM book WHERE id='".$id."'");
$row = mysqli_fetch_array($r,MYSQLI_ASSOC);
$email->Subject='Ответ на заказ N '.$id.': '.$row['zag'];
}
if(!$email->send())
{
echo "Mailer Error: " . $email->ErrorInfo;
}
else
{
echo "Сообщение было успешно отправлено";
}
?>
<!DOCTYPE html>
<html lang="en">
<form name="form1" method="post" action="">
<font size=+1 color=red>*</font>Напишите текст :
<br>
<textarea id="textarea" name="message" cols="50" rows="9"></textarea>
<br>
<input class="submit" type="submit" name="Submit" value="Отправить" >
</form>
</html>