while ($apa = mysql_fetch_array($query)){
$username = print($apa['username']);
$pass = print(md5(md5($apa['password'])));
require '../phpmailer/PHPMailerAutoload.php';
require '../phpmailer/class.phpmailer.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'mail.royaleducation.web.id'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'xxxxxx'; // SMTP username
$mail->Password = 'xxxxxx'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->setFrom($email,$name);
$mail->addAddress($email); // Add a recipient
$mail->addReplyTo($email);
$mail->isHTML(true); // Set email format to HTML>
$mail->msgHTML(
"<center><h1>Your data</h1></center><br><br>
username =".$username."<br>
password =".$password
);
$ username 和 $ password 不会出现.. 我在 $ username 和 $ password 之后放置打印是错误的吗? 或者有另一种方法在phpmailer中打印出值?因为如果我在 $ mail-&gt; msgHTML 中键入 或 echo ,则会出现错误
答案 0 :(得分:1)
如果您使用print
功能,参数会在输出中显示,print
始终返回1,因此您无法使用分配值。
如果您有问题$mail->msgHTML
功能,可以使用$mail->Body
,如下所示:
while ($apa = mysql_fetch_array($query)){
$username = $apa['username'];
$pass = md5(md5($apa['password']));
require '../phpmailer/PHPMailerAutoload.php';
require '../phpmailer/class.phpmailer.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'mail.royaleducation.web.id'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'idxxxx'; // SMTP username
$mail->Password = 'xxxxx'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->setFrom($email,$name);
$mail->addAddress($email); // Add a recipient
$mail->addReplyTo($email);
$mail->isHTML(true); // Set email format to HTML>
$mail->Body ="<center><h1>Your data</h1></center><br><br>username =".$username."<br>password =".$password;