2013-04-02 2 views
0

Функция PHP mail() прекратила отправлять мои письма. Я поговорил с моим поставщиком услуг, и они сказали, что я должен использовать SMTP, но я не профессиональный разработчик php. Они попытались дать небольшую помощь, и они предоставили мне сценарий, который отправляет мне электронное письмо, когда пользователь отправляет форму, но моя старая форма использовала для отправки мне по электронной почте данных clent, а также электронной почты с подтверждением электронной почты клиенту ,Замена скрипта почты() с помощью скрипта SMTP

Новый скрипт, который я создал, как отправить письмо с подтверждением для клиента, но я не знаю, как отправить письмо с этим скриптом, можете ли вы сказать мне, что я должен добавить, чтобы заставить его работать?

if(isset($_POST['submit'])) 

{ 

$title   = $_POST['title']; 
$name   = $_POST['name']; 
$surname  = $_POST['surname']; 
$phone   = $_POST['phone']; 
$visitor_email = $_POST['email']; 
$address  = $_POST['address']; 
$postcode  = $_POST['postcode']; 
$state   = $_POST['us']; 
$details  = $_POST['details']; 
$reasons  = $_POST['re']; 
$content  = $_POST['message']; 

require("class.phpmailer.php"); 

$mail = new PHPMailer(); 

//Your SMTP servers details 

// set mailer to use SMTP 
$mail->IsSMTP(); 

// specify main and backup server or localhost/your mail server yourmailserver.com 
$mail->Host = "xxxxxx.example.com"; 

// turn on SMTP authentication 
$mail->SMTPAuth = true;  

// SMTP username 
$mail->Username = "[email protected]"; 

$mail->Password = "**********"; // SMTP password 
//It should be same as that of the SMTP user 

$redirect_url = "http://".$_SERVER['SERVER_NAME']; //Redirect URL after submit the form 

//$mail->From = $mail->Username; //Default From email same as smtp user 
$mail->FromName = "Admin"; 

//Email address where you wish to receive/collect those emails. 
$mail->AddAddress($visitor_email, ""); 

$mail->WordWrap = 50;// set word wrap to 50 characters 
$mail->IsHTML(true);// set email format to HTML 

$mail->Subject = 'You have mail from: www.example.com'; 


// ** Build the Message 
$message = "<h4><b>We received your query</b></h4><br/><br/>"; 
$message .="Thankyou for contacting example.net.<br/>"; 
$message .="<br>"; 
$message .="Regards,<br/>"; 
$message .="admin"; 



$mail->Body = $message; 

//header("Location: thank-you.html"); 
if(!$mail->Send()) 
{ 
    header('Location: thank-you.html'); 
    // echo "Message could not be sent. <p>"; 
    // echo "Mailer Error: " . $mail->ErrorInfo; 
    exit; 
} 

header('Location: thank-you.html'); 



} 
else{ 
    header('Location: contact-us.html'); 
} 
?> 




// ******** Second update 
<? 
ob_start(); 
if(isset($_POST['submit'])) 

{ 

$title   = $_POST['title']; 
$name   = $_POST['name']; 
$surname  = $_POST['surname']; 
$phone   = $_POST['phone']; 
$visitor_email = $_POST['email']; 
$address  = $_POST['address']; 
$postcode  = $_POST['postcode']; 
$state   = $_POST['us']; 
$details  = $_POST['details']; 
$reasons  = $_POST['re']; 
$content  = $_POST['message']; 

require("class.phpmailer.php"); 

$mail = new PHPMailer(); 

//Your SMTP servers details 

// set mailer to use SMTP 
$mail->IsSMTP(); 

// specify main and backup server or localhost/your mail server yourmailserver.com 
$mail->Host = "xxx.example.net"; 

// turn on SMTP authentication 
$mail->SMTPAuth = true;  

// SMTP username 
$mail->Username = "*****@example.net"; 

$mail->Password = "********"; // SMTP password 
//It should be same as that of the SMTP user 

$redirect_url = "http://".$_SERVER['SERVER_NAME']; //Redirect URL after submit the form 

//$mail->From = $mail->Username; //Default From email same as smtp user 
$mail->FromName = "Admin vueproperty"; 

$mail->AddAddress($visitor_email, ""); //Email address where you wish to receive/collect those emails. 
//$mail->AddCC($_POST['email']); // ** Client email 
$mail->WordWrap = 50;// set word wrap to 50 characters 
$mail->IsHTML(true);// set email format to HTML 

$mail->Subject = 'You have mail from: www.exmple.net'; 


// ** Build the Message 
$message = "<h4><b>We received your query</b></h4><br/><br/>"; 
$message .="Thank you for contacting example.net. A property consultant will be in contact with you asap.<br/>"; 
$message .="<br>"; 
$message .="Regards,<br/>"; 
$message .="The example Team"; 



$mail->Body = $message; 

//header("Location: thank-you.html"); 

if($mail->Send()) 
{ 
    $body = "Name: $name<br/>"; 
    $body .= "Phone: $phone<br/>"; 
    $body .= "Email: $visitor_email<br/>"; 
    $mail->AddAddress('[email protected]', "MINE"); 
    if($mail->Send()){ 
     header('Location: thank-you.html'); 
     exit; 
    } 
} 





} 

?> 
// ******** Third update 
<? 
ob_start(); 
if(isset($_POST['submit'])) 

{ 

$title   = $_POST['title']; 
$name   = $_POST['name']; 
$surname  = $_POST['surname']; 
$phone   = $_POST['phone']; 
$visitor_email = $_POST['email']; 
$address  = $_POST['address']; 
$postcode  = $_POST['postcode']; 
$state   = $_POST['us']; 
$details  = $_POST['details']; 
$reasons  = $_POST['re']; 
$content  = $_POST['message']; 

require("class.phpmailer.php"); 

$mail = new PHPMailer(); 

//Your SMTP servers details 

// set mailer to use SMTP 
$mail->IsSMTP(); 

// specify main and backup server or localhost/your mail server yourmailserver.com 
$mail->Host = "xxx.example.net"; 

// turn on SMTP authentication 
$mail->SMTPAuth = true;  

// SMTP username 
$mail->Username = "*****@example.net"; 

$mail->Password = "********"; // SMTP password 
//It should be same as that of the SMTP user 

$redirect_url = "http://".$_SERVER['SERVER_NAME']; //Redirect URL after submit the form 

//$mail->From = $mail->Username; //Default From email same as smtp user 
$mail->FromName = "Admin vueproperty"; 

$mail->AddAddress($visitor_email, ""); //Email address where you wish to receive/collect those emails. 
//$mail->AddCC($_POST['email']); // ** Client email 
$mail->WordWrap = 50;// set word wrap to 50 characters 
$mail->IsHTML(true);// set email format to HTML 

$mail->Subject = 'You have mail from: www.exmple.net'; 


// ** Build the Message 
$message = "<h4><b>We received your query</b></h4><br/><br/>"; 
$message .="Thank you for contacting example.net. A property consultant will be in contact with you asap.<br/>"; 
$message .="<br>"; 
$message .="Regards,<br/>"; 
$message .="The example Team"; 



$mail->Body = $message; 

//header("Location: thank-you.html"); 

if($mail->Send()) 
{ 
    $body = "Name: " . $name . "<br/>"; 
    $body .= "Phone: " . $phone . "<br/>"; 
    $body .= "Email: ". $visitor_email . "<br/>"; 
    $mail->body = $body; 
    $mail->AddAddress('[email protected]', "MINE"); 
    if($mail->Send()) 
    { 
     header('Location: thank-you.html'); 
     exit; 
    } 

} 




} 

?> 

// * *** Пятое обновление

<? 
ob_start(); 
if(isset($_POST['submit'])) 

{ 

$title   = $_POST['title']; 
$name   = $_POST['name']; 
$surname  = $_POST['surname']; 
$phone   = $_POST['phone']; 
$visitor_email = $_POST['email']; 
$address  = $_POST['address']; 
$postcode  = $_POST['postcode']; 
$state   = $_POST['us']; 
$details  = $_POST['details']; 
$reasons  = $_POST['re']; 
$content  = $_POST['message']; 

require("class.phpmailer.php"); 

$mail = new PHPMailer(); 

//Your SMTP servers details 

// set mailer to use SMTP 
$mail->IsSMTP(); 

// specify main and backup server or localhost/your mail server yourmailserver.com 
$mail->Host = "xxx.example.net"; 

// turn on SMTP authentication 
$mail->SMTPAuth = true;  

// SMTP username 
$mail->Username = "*****@example.net"; 

$mail->Password = "********"; // SMTP password 
//It should be same as that of the SMTP user 

$redirect_url = "http://".$_SERVER['SERVER_NAME']; //Redirect URL after submit the form 

//$mail->From = $mail->Username; //Default From email same as smtp user 
$mail->FromName = "Admin vueproperty"; 

$mail->AddAddress($visitor_email, ""); //Email address where you wish to receive/collect those emails. 
//$mail->AddCC($_POST['email']); // ** Client email 
$mail->WordWrap = 50;// set word wrap to 50 characters 
$mail->IsHTML(true);// set email format to HTML 

$mail->Subject = 'You have mail from: www.exmple.net'; 


// ** Build the Message 
$message = "<h4><b>We received your query</b></h4><br/><br/>"; 
$message .="Thank you for contacting example.net. A property consultant will be in contact with you asap.<br/>"; 
$message .="<br>"; 
$message .="Regards,<br/>"; 
$message .="The example Team"; 



$mail->Body = $message; 


if($mail->Send()) 
{ 
    $body = "Name: " . $name . "<br/>"; 
    $body .= "Phone: " . $phone . "<br/>"; 
    $body .= "Email: ". $visitor_email . "<br/>"; 
    $mail->Body = $body; 
    $mail->AddAddress('[email protected]', "MINE"); 
    if($mail->Send()) 
    { 
     header('Location: thank-you.html'); 
     exit; 
    } 

} 

}

?> 

//// * ** * Шестой обновить ТЕПЕРЬ это ' s работает он

<? 
    ob_start(); 
    if(isset($_POST['submit'])) 

    { 

    $title   = $_POST['title']; 
    $name   = $_POST['name']; 
    $surname  = $_POST['surname']; 
    $phone   = $_POST['phone']; 
    $visitor_email = $_POST['email']; 
    $address  = $_POST['address']; 
    $postcode  = $_POST['postcode']; 
    $state   = $_POST['us']; 
    $details  = $_POST['details']; 
    $reasons  = $_POST['re']; 
    $content  = $_POST['message']; 

    require("class.phpmailer.php"); 

    $mail = new PHPMailer(); 

    //Your SMTP servers details 

    // set mailer to use SMTP 
    $mail->IsSMTP(); 

    // specify main and backup server or localhost/your mail server yourmailserver.com 
    $mail->Host = "xxx.example.net"; 

    // turn on SMTP authentication 
    $mail->SMTPAuth = true;  

    // SMTP username 
    $mail->Username = "*****@example.net"; 

    $mail->Password = "********"; // SMTP password 
    //It should be same as that of the SMTP user 

    $redirect_url = "http://".$_SERVER['SERVER_NAME']; //Redirect URL after submit the form 

    //$mail->From = $mail->Username; //Default From email same as smtp user 
    $mail->FromName = "Admin vueproperty"; 

    $mail->AddAddress($visitor_email, ""); //Email address where you wish to receive/collect those emails. 
    //$mail->AddCC($_POST['email']); // ** Client email 
    $mail->WordWrap = 50;// set word wrap to 50 characters 
    $mail->IsHTML(true);// set email format to HTML 

    $mail->Subject = 'You have mail from: www.exmple.net'; 


    // ** Build the Message 
    $message = "<h4><b>We received your query</b></h4><br/><br/>"; 
    $message .="Thank you for contacting example.net. A property consultant will be in contact with you asap.<br/>"; 
    $message .="<br>"; 
    $message .="Regards,<br/>"; 
    $message .="The example Team"; 



    $mail->Body = $message; 

    $mail->Send(); 
     $mail->ClearAllRecipients(); 
     $body = "Name: " . $name . "<br/>"; 
     $body .= "Phone: " . $phone . "<br/>"; 
     $body .= "Email: ". $visitor_email . "<br/>"; 
     $mail->Body = $body; 
     $mail->AddAddress('[email protected]', ""); 
     if($mail->Send()) 
     { 
     $mail->ClearAllRecipients(); 
     header('Location: thank-you.html'); 
     exit; 
    } 

} 
+0

'class.phpmailer.php' Это говорит вам много. Google расскажет вам что-то еще. Ваши усилия и желание должны сделать все остальное –

+0

спасибо, Damine - у меня есть интернет в Интернете, но я не могу найти что-то полезное. у вас есть сайт, который может помочь ...? –

ответ

1

если я точно понимаю ваш вопрос. вы смогли отправить электронное письмо своему клиенту, но вы хотите отправить его и вам.

если это случай. добавить еще одного регистратора $mail->AddAddress($visitor_email, "MY_CLIENT");

EDIT: сначала получите красную от второй линии.

if($mail->Send()){$message = "ALL REQUIRED DATA YOU WANT TO SEND TO YOURSELF";$mail->AddAddress('[email protected]', "MINE");if($mail->Send()){header('Location: thank-you.html');exit;}} 
+0

вся ваша база принадлежит нам – lamarant

Смежные вопросы