0

PHP 的mail()功能已停止发送我的电子邮件。我与我的服务提供商交谈,他们说我必须使用 SMTP,但我不是专业的 php 开发人员。他们试图提供一点帮助,他们为我提供了一个脚本,当用户提交表单时,它会向我发送电子邮件,但我的旧表单用于向我发送电子邮件数据以及确认电子邮件给客户.

我已经管理了一些如何为客户发送确认电子邮件的新脚本,但我不知道如何使用此脚本发送电子邮件,你能告诉我应该添加什么以使其工作吗?

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 = "me@xxxxx.com";  

$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('xphpxmysql@gmail.com', "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('xphpxmysql@gmail.com', "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('xphpxmysql@gmail.com', "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;

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

}
4

1 回答 1

1

如果我完全理解你的问题。您可以将电子邮件发送给您的客户,但您也想将其发送给您。

如果是这样的话。添加另一个接待员$mail->AddAddress($visitor_email, "MY_CLIENT");

编辑:首先得到第二行的红色。

    if($mail->Send()){$message = "ALL REQUIRED DATA YOU WANT TO SEND TO YOURSELF";$mail->AddAddress('YOUREMAIL@EXAMPLE.COM', "MINE");if($mail->Send()){header('Location: thank-you.html');exit;}}
于 2013-04-02T21:01:05.973 回答