phpmailer 相关问题

PHPMailer是一个PHP电子邮件传输类。 PHPMailer旨在与其他服务器直接通信(与PHP的本机mail()函数不同)。与[php]标签一起使用

PHPMailer 验证失败

当我在工作中尝试在 Windows Server 2012 上使用 PHPMailer 使用 SMTP 发送报告电子邮件时,出现身份验证失败错误。 我在域上使用服务器管理员帐户。 我很确定...

回答 3 投票 0

如何将PHP联系网页连接到Thunderbird

我是编码新手,我需要帮助。我基本上一直使用 ChatGPT 作为拐杖,同时从头开始自学 CSS、HTML、PHP 和其他一些语言。 我在一家初创公司工作。我创造...

回答 1 投票 0

需要帮助将 PHP 联系网页连接到 Thunderbird

我是编码新手,我需要帮助。我基本上一直使用 ChatGPT 作为拐杖,同时从头开始自学 CSS、HTML、PHP 和其他一些语言。 我在一家初创公司工作。我创造...

回答 1 投票 0

phpmailer 发送电子邮件的时间超过 20 秒

我面临 phpmailer 发送电子邮件非常慢的问题....发送大约需要 25-30 秒。电子邮件已送达,但脚本执行时间更长... 我创建了一个简单的 test.php 进行测试......

回答 1 投票 0

PHP Mailer 编译并存储消息以供稍后发送

我们可以将消息编译并存储为 PHP 邮件程序中的草稿,然后再发送每条消息吗?

回答 6 投票 0

为什么 SMTP 错误?当我在本地主机上运行时它可以工作。但是当我把我的服务器 SMTP 错误。有人可以解释一下吗?

使用 PHPMailer\PHPMailer\PHPMailer; 使用 PHPMailer\PHPMailer\Exception; 使用 PHPMailer\PHPMailer\SMTP; //加载Composer的自动加载器 需要“供应商/autoload.php”; 函数 send_password_reset($get_n...

回答 1 投票 0

尝试通过 XOAUTH2 使用 smtp.gmail.com 进行身份验证

我正在使用 PHPMailer 通过 XOAUTH2 与 smtp.gmail.com 进行身份验证,以便发送电子邮件。但是,我收到身份验证错误且响应不充分: 2023-11-17 06:32:29 服务器...

回答 1 投票 0

重用 PHPMailer 发送第二封电子邮件?

我正在开发一个订购系统,需要向客户、经销商和网站所有者发送一封电子邮件。 所有者和经销商可以收到相同的电子邮件(订单详细信息等),但

回答 2 投票 0

Strato - 通过 phpmailer 将邮件放入已发送文件夹中

我发现了这个问题,与我的类似:Sent mails with phpmailer don't go to "Sent" IMAPfolder 我想在已发送文件夹中查看我的邮件,该邮件是由 phpmailer 发送的。

回答 1 投票 0

为什么我在使用 PHPMailer 时会在 VisualCode 中收到“未知类”的警告?

我很难理解为什么我在 Visual Studio Code 中收到此警告: 我已经为我的网站实现了一些邮寄功能(例如,在邮寄确认请求或新闻通讯时)。我是

回答 1 投票 0

getSentMIMEMessage() 中缺少密件抄送字段

我正在尝试使用 phpmailer() 创建 MIME 消息。 一切正常,但当我读取 MIME 消息时,密件抄送字段丢失。 我正在使用以下技术来创建 MIME 消息。 $mail->p...

回答 2 投票 0

我应该如何从PHPMailer 5.2升级到6.0?

我有一个脚本,当前使用最新版本的 PHPMailer 5.2.x。 PHPMailer 6.0 已发布,但表示它将破坏向后兼容性 – 我需要做什么才能升级? 我有一个当前使用最新版本的 PHPMailer 5.2.x 的脚本。 PHPMailer 6.0 已发布,但表示它将破坏向后兼容性 – 我需要做什么才能升级? <?php require 'PHPMailerAutoload.php'; $mail = new PHPMailer; //$mail->SMTPDebug = 3; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = '[email protected]'; // SMTP username $mail->Password = 'secret'; // SMTP password $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted $mail->Port = 587; // TCP port to connect to $mail->setFrom('[email protected]', 'Mailer'); $mail->addAddress('[email protected]', 'Joe User'); // Add a recipient $mail->addAddress('[email protected]'); // Name is optional $mail->addReplyTo('[email protected]', 'Information'); $mail->addCC('[email protected]'); $mail->addBCC('[email protected]'); $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name $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'; if(!$mail->send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; } else { echo 'Message has been sent'; } PHPMailer 6.0 中发生的主要变化: 需要 PHP 5.5 或更高版本(5.0 以上) 使用命名空间 类文件名和位置已更改 其他不相关的“额外”课程已被删除 还有许多其他较小的更改,您可以在变更日志以及官方升级指南中阅读,但这些是最有可能影响您的。 通过composer升级 要通过 Composer 升级,请更改 require 文件的 composer.json 部分中的条目,然后运行 composer update phpmailer/phpmailer: "phpmailer/phpmailer": "~6.0" 这将仅更新 PHPMailer,并且不会触及任何其他依赖项。 PHPMailer 使用 semver 版本编号策略,该模式将匹配 6.x 系列中的所有未来版本。这是对之前推荐的 ~5.2 模式的更改。 加载类文件 对于给出的示例脚本,我们主要需要更改类的加载方式。自动加载器不再存在,因此您要么需要使用 Composer(在这种情况下,您不需要更改任何内容 - 标准 Composer 自动加载器会自动执行此操作),或者您需要自己加载类。 与作曲家: require 'vendor/autoload.php'; 没有作曲家: require 'src/PHPMailer.php'; require 'src/SMTP.php'; require 'src/Exception.php'; 命名空间 PHPMailer 类位于 PHPMailer\PHPMailer 命名空间中,因此您需要在该命名空间中工作,或者将它们导入到您自己的命名空间或全局命名空间中,例如: //Import PHPMailer classes into the global namespace use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; 请注意,这些必须放在 require 行之前。之后,您可以使用您习惯的原始类名: $mail = new PHPMailer; 或者,您可以直接引用它们的完全限定名称,而不使用 use 语句,例如: $mail = new PHPMailer\PHPMailer\PHPMailer; 这个类以这个“三重名称”结尾的原因是因为它是 PHPMailer 类,位于 PHPMailer 项目中,由 PHPMailer 组织拥有。这使得它能够与 PHPMailer 的其他分支、PHPMailer 组织的其他项目以及项目中的其他类区分开来。 例外情况 除了名称从phpmailerException更改之外,异常的工作方式与以前的版本相同,但捕获时需要注意名称空间: use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; $mail = new PHPMailer(true); try { ... } catch Exception($e) { //$e is an instance of PHPMailer\PHPMailer\Exception } catch \Exception ($e) { //$e is an instance of the PHP built-in Exception class } 文档 6.0 的所有文档和示例代码也已更新。最好的起点是 自述文件 或 项目 wiki ,您可以在其中找到非常流行的 故障排除指南 、大量教程和 生成的 API 文档 的链接。如果您刚刚开始,请根据示例文件夹中提供的示例编写代码。 寻求帮助 如果您在使用 PHPMailer 时遇到问题,首先在 Stack Overflow 上并在 PHPMailer 标签下搜索您的特定错误消息。如果您认为您在 PHPMailer 中发现了错误,请在 github 项目 上报告(提示 - 无法从 GoDaddy 服务器连接到邮件服务器不是 PHPMailer 错误!) 以上配置对我来说是有效的。谢谢上传者。

回答 2 投票 0

使用“include”加载 PHPMailer

安装在任何网站上的应用程序都将使用 PHPMailer 包发送电子邮件。我不想在应用程序中分发 PHPMailer“包”(文件)。 我可以加载吗

回答 1 投票 0

PHPMailer - 无法获取完整的错误消息

如果可能的话请寻求有关我的 PHPMailer 代码的帮助。 总的来说,它工作得很好,我正在努力捕获的是具体的错误消息。 if (!$mail->send()) { 回显“邮件 如果可能,请寻求有关我的 PHPMailer 代码的帮助。 总的来说,它工作得很好,我正在努力捕获的是具体的错误消息。 if (!$mail->send()) { echo "Mail <font color=red><b>Not</font></b> Sent to $address - Error: $mail>ErrorInfo<br>"; } else { echo "Mail <font color=green><b>Successfully</font></b> Sent to $address<br>"; } 这工作正常,但我收到的无效地址的错误信息例如是:You must provide at least one recipient email address 如果我查看实际的调试日志,我可以看到一个实际的错误: Invalid address: (bcc): steven.rothera.com 任何人都可以帮我获取它,以便我可以回显实际的错误消息吗? 我查看了很多其他帖子,试图帮助我弄清楚这一点,但到目前为止还没有运气。 为了掩盖一些存在的代码: use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; $mail = new PHPMailer(true); $mail->SMTPDebug = 2; $mail->Debugoutput = function($str, $level) { $fp = fopen('/var/log/phpmailer.log','a'); fwrite($fp, date('d-m-Y H:i:s') . "\t" . $str); fclose($fp); }; 我也尝试过使用异常,但这没有显示任何错误: try { $mail->send(); echo 'Message sent!'; } catch (Exception $e) { echo $e->errorMessage(); //Pretty error messages from PHPMailer } catch (\Exception $e) { echo $e->getMessage(); //Boring error messages from anything else! } 这是代码的更新版本,其中包含一些修改和其他调试建议: use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; $mail = new PHPMailer(true); try { // your code to configure PHPMailer // Attempt to send the email $mail->send(); echo 'Message sent!'; } catch (Exception $e) { // PHPMailer specific exception echo 'Mailer Error: ' . $e->getMessage(); } catch (\Exception $e) { // Generic exception echo 'An error occurred: ' . $e->getMessage(); } // Additional Debugging Information echo 'Debug Output:<br>'; echo nl2br(file_get_contents('/var/log/phpmailer.log')); 确保执行以下操作: 文件权限 检查 SMTP 连接

回答 1 投票 0

Mailer 错误:无法实例化邮件功能

我尝试过以下脚本通过phpmailer发送邮件 我尝试过以下脚本通过phpmailer发送邮件 <?php $sendfrm_name = 'Balakumar B'; $sendfrm_id = '[email protected]'; $sendtoname = 'myself'; $sendto = '[email protected]'; //$cc = ''; include("mail/PHPMailerAutoload.php"); include("mail/class.PHPMailer.php"); include("mail/class.smtp.php"); $mail = new PHPMailer; //$mail-> isSMTP(); $mail-> Host = 'mail.mydomain.com'; //smtp.gmail.com $mail->SMTPDebug = 2; $mail-> SMTPAuth = true; $mail->smtpConnect = array( 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true ) ); $mail-> Username = '[email protected]'; $mail-> Password = 'balakumar1`2345'; $mail-> SMTPSecure = 'tls'; $mail-> Port = 465; //587 $mail-> setFrom($sendfrm_id, $sendfrm_name); $mail-> addAddress($sendto, $sendtoname); $mail-> addReplyTo($sendto, $sendtoname); //$mail->addCC($cc); $mail->WordWrap = 50; $mail->isHTML(true); $mail->Subject = "Test Mail"; $mail->Body = "Name: ".$sendfrm_name ."<br /> Email: ".$sendfrm_id; if(!$mail->send()) { echo "Mailer Error: ".$mail->ErrorInfo; } else { echo ("<p>Message successfully sent!</p>"); echo "E-mail: ", $sendto, "<br />"; echo "Name: ", $sendtoname, "<br />"; echo "Subject: Test Mail<br />"; echo "Body: Body Of the Mail<br />"; } ?> 但我收到邮件错误: 无法实例化邮件功能。 如何修复这个错误?上面我提到了我的邮件服务器 (mail.mydomain.com) 和端口 465。 您使用的代码是 php 的默认 mail() 函数。您需要使用 SMTP。 您已禁用 SMTP。 $mail = new PHPMailer; //$mail-> isSMTP(); <----------- Here it is disabled. $mail-> Host = 'mail.mydomain.com'; //smtp.gmail.com $mail->SMTPDebug = 2; $mail-> SMTPAuth = true; 因为 SMTP 被禁用,所以它正在使用 mail() 功能。您的机器配置不正确。 只需取消注释该行即可。 完整代码在这里: $mail = new PHPMailer; $mail-> isSMTP(); # SMTP is enabled now. $mail-> Host = 'mail.mydomain.com'; //smtp.gmail.com $mail->SMTPDebug = 2; $mail-> SMTPAuth = true; 希望这有帮助。 你在这里做了很多错误的事情,我看不出有什么特别的原因。 当您使用自动加载器时,您不需要加载其他类 - 这就是自动加载器的用途。您似乎已将 class.phpmailer.php 的文件名更改为 class.PHPMailer.php,这是非标准的,在区分大小写的文件系统上会遇到问题,并且在更新库时可能会中断。 如果您不调用 isSMTP(),您将不会使用 SMTP,因此不会使用任何 SMTP 设置(默认情况下将使用 PHP mail() 函数)。 如果您使用 SMTPSecure = 'tls',则需要 Port = 587,而不是 465。 为什么要禁用证书验证?您应该仅出于非常具体的原因才这样做,而不仅仅是作为“使其发挥作用”的随机措施。它存在安全风险,因此除非绝对必要,否则不要这样做,并且您知道确切的原因 - 如果您不知道,请不要这样做。 无需调用 WordWrap - 它还表明您的代码基于旧示例,并且可能正在运行旧版本的 PHPMailer,因此 获取最新版本。 为什么要将收件人地址和回复地址设置为相同?

回答 2 投票 0

PHPMailer 邮件程序错误:消息正文为空

我正在尝试让基本示例适用于 PHPMailer。 我所做的就是上传整个 PHPMailer_5.2.2 文件夹,根据您看到的代码配置下面的页面,但我不断收到 Mailer 错误:

回答 5 投票 0

即使从沙箱转移到生产环境,也无法通过 Amazon SES 向未经验证的电子邮件地址发送电子邮件

即使从沙箱环境转移到生产环境后,我仍然无法使用 PhpMailer 通过 Amazon SES 向未经验证的电子邮件地址发送电子邮件。不过,我可以将其发送给经过验证的电子...

回答 1 投票 0

使用 PHP 和 Gmail 通过 SMTP 发送邮件无法到达

我有使用使用 Gmail 的 phpMailer 的 PHP 代码。当终端打开 PHP 存档时,电子邮件到达了应有的位置,但是当我上传到服务器时,电子邮件刚刚到达...

回答 1 投票 0

如何将 PHPMailer 与 Codeigniter 3 集成

嗨,我正在尝试在我的 Codeigniter 应用程序中使用来自 GitHUB 的 PHPMailer 库。 我下载了代码并解压缩到我的 application\library 文件夹中。 所以我里面有一个名为供应商的文件夹

回答 4 投票 0

PHPMailer - 无法连接到 SMTP 主机

尝试使用 Gmail SMTP 服务器在 BlueHost VPS 上实施 PHPMailer。失败并显示“消息无法发送。邮件程序错误:SMTP 错误:无法连接到 SMTP 主机。”拥有应用程序密码...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.