本文介绍了PHPMailer的半期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PHPMailer出现一个奇怪的问题,当我尝试发送电子邮件时,出现以下错误:escapeshellcmd() has been disabled for security reasons,但是如果我检查电子邮件,可以看到电子邮件已发送,如何解决/隐藏此问题?

I have a strange issue with PHPMailer, when I try to send an email I see this error: escapeshellcmd() has been disabled for security reasons but if I check the email, I can see that the email is sent, how can I fix/hide this problem?

推荐答案

使用下面的代码,希望对您有所帮助:

Use this code that's it, hope it will help:

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
$mail = new PHPMailer(true);
$name = 'Your Name';
$to = 'to@gmail.com';
$subject = 'Hello World!';
$message = 'This is a test mail!';
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->Username = 'yourmail@gmail.com';
$mail->Password = '*********';
$mail->SMTPSecure = 'tls';
$mail->addReplyTo($to, $name);
$mail->setFrom($to, $name);
$mail->addAddress($to);
$mail->Subject = $subject;
$mail->msgHtml($message);
$mail->send();

只需更改电子邮件和密码并运行.

Simply change email & password and run.

谢谢!

这篇关于PHPMailer的半期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 14:33