在 Laravel 7 中使用 PHP Mailer 发送邮件

Mail sending using PHP Mailer in Laravel 7

我在 Laravel 7 中使用 PHPMailer。邮件工作正常。发送邮件成功。但是在点击 'send' 按钮之后,它会显示一些关于服务器的行,显示成功消息。

这几行显示 -

2021-01-04 19:27:49 SERVER -> CLIENT: xxxx
2021-01-04 19:27:49 CLIENT -> SERVER: 
2021-01-04 19:27:49 SERVER -> CLIENT: 
2021-01-04 19:27:49 SERVER -> CLIENT: xxxxx
2021-01-04 19:27:49 CLIENT -> SERVER: xxxx
2021-01-04 19:27:49 SERVER -> CLIENT: xxxx

我的控制器代码:

 public function jobApply(Request $request)
    {
        $resume = Resume::where('candidate_id', Auth::guard('candidate')->user()->id)->first();
        $compEmail = $request->txt_compEmail;
        $cadEmail = $request->txt_candEmail;
        $subject = $request->txt_subject;
        $body = $request->txt_candSalary;
        $file = $resume->resume;
        $mail = new PHPMailer(true);
        try {
            //Server settings
            $mail->SMTPDebug = SMTP::DEBUG_SERVER;
            $mail->isSMTP();
           // Send using SMTP
            $mail->Host       = env('MAIL_HOST'); 
            // Set the SMTP server to send through
            $mail->SMTPAuth   = true;
            // Enable SMTP authentication
            $mail->Username   = env('MAIL_USERNAME');
            // SMTP username
            $mail->Password   = env('MAIL_PASSWORD');
           // SMTP password
            $mail->SMTPSecure = env('MAIL_ENCRYPTION');
            // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
            $mail->Port       = env('MAIL_PORT');
            Log::info("Check:".$mail->Host. ' '.$mail->Username.' '.$mail->Password.' '.$mail->SMTPSecure.' '.$mail->Port);// TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above

            //Recipients
            $mail->setFrom($cadEmail);
            $mail->addAddress($compEmail);
           // Add a recipient
            $mail->AltBody ='';
            $mail->addAttachment($file );
            // Content
            $mail->isHTML(true);
            // Set email format to HTML
            $mail->Subject = $subject;
            $mail->Body    = 'Expected Salary : ' . $body ;
            $mail->send();
        }  catch (Exception $e) {
            echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
//            dd($e);
        }
        if ($mail){
            return redirect()->back()->with('success','Mail Send Successfully..!!');
        }
        else{
            return redirect()->back()->with('error','Something Went Wrong')->withInput();
        }
    }

如何隐藏它?任何人都建议我任何解决方案。高级感谢。

您已要求它显示调试输出,所以它正在生成它。如果您不想要它,请不要打开它——注释掉这一行:

$mail->SMTPDebug = SMTP::DEBUG_SERVER;