2013-11-15 38 views
0

大家好我一直得到這個錯誤,不知道如何解決它。錯誤與PHPMailer

{ 「迴應」: 「錯誤」, 「消息」: 「您必須提供至少一個收件人 電子郵件地址」}

這是代碼。

<?php 

require_once('phpmailer/class.phpmailer.php'); 

$mail = new PHPMailer(); 

//recipient data 
$toemail = $_POST['[email protected]']; // Your Email Address 
$toname = $_POST['Spadaweb, INC']; // Your Name 

//sender data 
$name = $_POST['contact-form-name']; 
$email = $_POST['contact-form-email']; 
$service = $_POST['contact-form-service']; 
$subject = $_POST['contact-form-subject']; 
$message = $_POST['contact-form-message']; 


if(isset($_POST['contact-form-submit'])) { 

if($name != '' AND $email != '' AND $subject != '' AND $message != '') { 

    $body = "Name: $name <br><br>Email: $email <br><br>Service: $service <br>   <br>Message: $message"; 

    $mail->SetFrom($email , $name);  
    $mail->AddReplyTo($email , $name);    
    $mail->AddAddress($toemail , $toname);    
    $mail->Subject = $subject;    
    $mail->MsgHTML($body); 

    $sendEmail = $mail->Send(); 

    if($sendEmail == true): 
     $arrResult = array ('response'=>'success'); 
    else: 
     $arrResult = array ('response'=>'error','message'=>$mail->ErrorInfo);  
    endif; 
    } else { 
    $arrResult = array ('response'=>'empty');    
    } 

} else { 
    $arrResult = array ('response'=>'unexpected'); 
} 
echo json_encode($arrResult); 
?> 

我改變了電子郵件等我的,我不斷收到上述錯誤?目前託管在bluehost vps cent os服務器上。 DKIM在此特定帳戶上啓用?感謝您查看問題!

+1

'$ toemail = $ _POST ['[email protected]']' - 是您的輸入字段的名稱?這就是填充你的表單中名爲'contact @ spadaweb.com'的一個字段的內容。嘗試將它硬連線到'$ toemail ='contact @ spadaweb.com'',看看這是否有所作爲 – andrewsi

回答

2
$toemail = $_POST['[email protected]']; // Your Email Address 
$toname = $_POST['Spadaweb, INC']; // Your Name 

這需要改變,因爲你給它的實際變量,而不是試圖獲得帖子。

$toemail = '[email protected]'; // Your Email Address 
$toname = 'Spadaweb, INC'; // Your Name 

現在它應該能夠發送。

+0

Thankyou非常感謝,這將是非常簡單的事情! – Spade