如何使用变量发送消息

时间:2017-10-04 07:24:05

标签: php

$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("karthik.hansi@infysky.com", '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中,我想向输入的客户端发送动态消息。

1 个答案:

答案 0 :(得分:0)

你试过$mail->addAddress($email)吗?见https://github.com/PHPMailer/PHPMailer