在PHP中=之后回显或打印

时间:2017-05-29 03:17:36

标签: php phpmailer

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 ,则会出现错误

1 个答案:

答案 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;