程序问答   发布时间:2022-06-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了为什么我在 PHPmailer 中出现签名错误:error:02001002大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决为什么我在 PHPmailer 中出现签名错误:error:02001002?

开发过程中遇到为什么我在 PHPmailer 中出现签名错误:error:02001002的问题如何解决?下面主要结合日常开发的经验,给出你关于为什么我在 PHPmailer 中出现签名错误:error:02001002的解决方法建议,希望对你解决为什么我在 PHPmailer 中出现签名错误:error:02001002有所启发或帮助;

在这里使用 PHPmailer 遇到一个奇怪的问题。 我有几个脚本每天发送带有认证发件人签名的电子邮件,但是...

一个全新的PHP页面导致签名失败。当我删除 $mail->sign 时,电子邮件被发送,没有进一步的错误

所有电子邮件文件都来自同一个文件夹。

警告:tempnam():open_basedir 限制生效。文件(/tmp)是 不在允许的路径内: (/home/uploads_tmp:/home/PHP-scripts:/home/clIEnts/cineferte.fr/http) 在 /home/clIEnts/cineferte.fr/http/mail/PHPmailer/PHPmailer/src/PHPMailer.PHP 第 2892 行

警告:tempnam():open_basedir 限制生效。文件(/tmp)是 不在允许的路径内: (/home/uploads_tmp:/home/PHP-scripts:/home/clIEnts/cineferte.fr/http) 在 /home/clIEnts/cineferte.fr/http/mail/PHPmailer/PHPmailer/src/PHPMailer.PHP 第 2893 行

警告:file_put_contents():文件名不能为空 /home/clIEnts/cineferte.fr/http/mail/PHPmailer/PHPmailer/src/PHPMailer.PHP 在线 2894

致命错误:未捕获的异常 'PHPMailer\PHPMailer\Exception' with 消息'签名错误:错误:02001002:系统库:fopen:没有这样的 文件或目录'在 /home/clIEnts/cineferte.fr/http/mail/PHPmailer/PHPmailer/src/PHPMailer.PHP:2927 堆栈跟踪:#0 /home/clIEnts/cineferte.fr/http/mail/PHPmailer/PHPmailer/src/PHPMailer.PHP(1568): PHPMailer\PHPMailer\PHPMailer->createBody() #1 /home/clIEnts/cineferte.fr/http/mail/PHPmailer/PHPmailer/src/PHPMailer.PHP(1464): PHPMailer\PHPMailer\PHPMailer->preSend() #2 /home/clIEnts/cineferte.fr/http/mail/test.PHP(62): PHPMailer\PHPMailer\PHPMailer->send() #3 {main} 被抛出 /home/clIEnts/cineferte.fr/http/mail/PHPmailer/PHPmailer/src/PHPMailer.PHP 在线 2927

有什么线索吗?

谢谢

编辑: 为什么使用相同脚本的其他页面可以正常工作???

这是代码... .KEY、.PEM 和 .PEM 位于名为“邮件”的同一文件夹中

//import PHPMailer classes into the global namespace
//These must be at the top of your script,not insIDe a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
// use PHPMailer\PHPMailer\POP3;

//Load Composer's autoloader
require 'autoload.PHP';
// $pop = POP3::popBeforeSmtp('pop3.cineferte.fr',110,30,$user,$mdp,1);
//Instantiation and passing `true` enables exceptions
$mail = new PHPMailer(true);

try {
    //Server settings
    $mail->SMTPDeBUG = SMTP::DEBUG_SERVER; 
    $mail->isSMTP(); 
    $mail->Host       = 'smtp.cineferte.fr'; 
    $mail->SMTPAuth   = true; 
    $mail->Username   = 'user'; 
    $mail->Password   = 'password'; 
    $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS ;
    $mail->Port       = 465; 

//RecipIEnts
    $mail->setFrom('from@cineferte.fr','Mailer');
    $mail->addAddress('to@cineferte.fr','Joe User');

//Content
    $mail->isHTML(true);                                  //Set email format to HTML
    $mail->Subject = 'Here is the subject';
    $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
    $mail->Altbody = 'This is the body in plain text for non-HTML mail clIEnts';
    
//  DKIM
    $mail->DKIM_domain = 'cineferte.fr' ;
    $mail->DKIM_private = 'mail/dkim.private';
    $mail->DKIM_selector = 'selector' ;
    $mail->DKIM_passphrase = '';
    $mail->DKIM_IDentity = $mail->From ;
    $mail->DKIM_copyheaderFIElds = true;
    $mail->DKIM_extraheaders = ['List-Unsubscribe','List-Help'];

    $mail->sign(    'mail/gp.crt','mail/gp.key','xxxxxxx','mail/gp.pem' );
        
    $mail->send();
    echo 'Message has been sent';
} catch (Exception $e) {
    echo "Message Could not be sent. Mailer Error: {$mail->ErrorInfo}";

解决方法

在我发现结果似乎取决于变量来自哪个文件夹后,我设法通过更改 PHPMailer.php 中的一些内容来解决我的问题

#2888 & 2889

$file = tempnam($_SERVER['DOCUMENT_ROOT'].'/my_folder','srcsign');
$signed = tempnam($_SERVER['DOCUMENT_ROOT'].'/my_folder','mailsign');

我还必须在每个签名文件 $_SERVER['DOCUMENT_ROOT']..CRT,.PEM,.KEY 前添加 DKIM

大佬总结

以上是大佬教程为你收集整理的为什么我在 PHPmailer 中出现签名错误:error:02001002全部内容,希望文章能够帮你解决为什么我在 PHPmailer 中出现签名错误:error:02001002所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: