2017-10-04 87 views
-1
$mail = new PHPMailer(true); 
$mail->IsSMTP(); 
$mail->SMTPDebug = 0; 
$mail->SMTPAuth = true; 
$mail->SMTPSecure = 'ssl'; 
// $mail->Host = "smtp.gmail.com"; 
$mail->Host = "mail.infysky.com"; 
$port = $mail->Port = 465; 
//echo "<br />"; 
$mail->IsHTML(false); 

$name  = "'" . $params["txtName"] . "'"; 
$email  = "'" . $params["txtEmailID"] . "'"; 
$department = "'" . $params["selDepartment"] . "'"; 
$designation = "'" . $params["selDesignation"] . "'"; 
$leave  = "'" . $params["selLeave"] . "'"; 
$dateFrom = "'" . $params["txtDate1"] . "'"; 
$dateTo  = "'" . $params["txtDate2"] . "'"; 
$reason  = "'" . $params["txtReason"] . "'"; 

$mail->SetFrom("[email protected]", 'infy SKY'); 
$mail->Subject = "90%"; 
$mail->Body = "Message for leave apply \n NAME:  $name;\n E-MAIL  
$email;\n DEPARTMENT: $department; \n DESIGNATION: $designation;\n LEAVE 
TYPE: $leave;\n DATE FROM: $dateFrom;\n DATE TO:  $dateTo;\n REASON:  
$reason; "; 

$mail->AddAddress(); //To Address 
$mail->Send(); 

如何從PHP Mailer中的AddAddress變量發送消息。 在AddAddress中,我想發送動態消息到輸入的客戶端。如何使用變量發送消息

+0

郵件順利通過這段代碼發送只是我想$電子郵件發送的AddAddress – Karthik

+0

BRO I GOT解決方案 – Karthik

回答

0

你試過$mail->addAddress($email)?見https://github.com/PHPMailer/PHPMailer

+0

是的,我試過,但我得到電子郵件地址無效 – Karthik

+0

你可以打印出來或的var_dump()的內容你'$ email'變量? –

+0

我正在通過var_dump()傳遞的電子郵件地址,但仍然收到此錯誤消息致命錯誤:帶有消息'Unvalidaught address'的未捕獲異常'phpmailerException':[email protected]'' – Karthik