phpmailer 相关问题

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

使用 PHPMailer 发送 iCal - 但 Outlook/Thunderbird 无法识别 iCal

我使用通过office365发送带有iCal附件的电子邮件。 这些电子邮件有一个名为 calendar.ics 的附件。所有电子邮件客户端都会显示这些附件。但 Outlook 和 Thunderbird 都不是

回答 0 投票 0

PHPMailer 字符编码问题

我尝试使用PHPMailer发送注册、激活。等邮件给用户: require("class.phpmailer.php"); $mail -> charSet = "UTF-8"; $mail = new PHPMailer(); $mail->IsSMTP(); $邮件->...

回答 6 投票 0

PHP 邮件程序脚本无法在 IONOS 服务器上运行

PHP 初学者在这里尝试解决一个问题已经好几天了: 我正在尝试通过 IONOS 邮件服务器使用 PHP mail() 函数发送 html 邮件。 Html 很重要,因为我想设置

回答 2 投票 0

Phpmailer 未存储到已发送文件夹

后台上下文:使用 php8.1、Ubuntu 22.04 的新邮件服务器。旧服务器 php7.4,Debian Stretch 均使用 Phpmailer 5.5。 以前的服务器会发送带有附件的电子邮件并放置一份副本,其中包括...

回答 1 投票 0

phpmailer 和 gmail SMTP 错误:无法连接到服务器:网络无法访问 (101) SMTP connect() 失败

我需要帮助,请 这是我的代码: 需要“PHPMailerAutoload.php”; $mail = 新的 PHPMailer; $mail->isSMTP(); $mail->主机 = "smtp.gmail.com"; $mail->SMTPDebug = 2; $mail->SMTPAuth = true...

回答 6 投票 0

phpmailer 与 yahoo 在任何设置下都无法工作

所以我一直在使用 gmail 并使用 php 邮件程序,它工作得很好。 我尝试对雅虎邮件执行相同的操作,但似乎不起作用。 我尝试了各种端口和设置,但不是

回答 4 投票 0

这条消息总是让我暂时进入雅虎黑名单。有什么问题吗

每当我向雅虎发送此消息时,我都会立即收到临时阻止。我只将其发送给自己,因此没有进行垃圾邮件报告。 # 之前声明的所有变量... $mail = new PHPMailer(true...

回答 1 投票 0

PHPMailer - 使用 URL 附加远程文件

PHPMailer 检查每个附件的 is_file (在 addAttachment 函数中,在 class.phpmailer.php 文件中): if (!@is_file($path)) { 抛出新的 phpmailerException($this->lang('file_access') 。$pa...

回答 4 投票 0

PhpMailer 返回“无法连接到 SMTP 主机”错误

下面是我的代码,用于在用户提交请求后向审批者发送电子邮件。电子邮件将首次发送给审批者,但是,在向审批者发送多封电子邮件后,我...

回答 1 投票 0

PHPmailer 使用不同的电子邮件地址进行身份验证和设置

我使用一个 Gmail 帐户进行身份验证,并在 PHPmailer 的回复中使用另一个 Gmail 地址。电子邮件运行正常,但不确定这在电子邮件传递方面是否是一个好的做法......

回答 1 投票 0

如何设置phpmailer自动回复?

请指导我如何根据我的代码设置自动回复电子邮件: 以下代码运行良好,所有电子邮件都将毫无问题地进入收件箱文件夹。 请指导我如何根据我的代码设置自动回复电子邮件: 以下代码运行良好,所有电子邮件都将毫无问题地进入收件箱文件夹。 <?php sleep(3); $recipients = 'recipients-email'; try { require './phpmailer/PHPMailerAutoload.php'; preg_match_all("/([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)/", $recipients, $addresses, PREG_OFFSET_CAPTURE); if (!count($addresses[0])) { die('MF001'); } if (preg_match('/^(127\.|192\.168\.)/', $_SERVER['REMOTE_ADDR'])) { die('MF002'); } $template = file_get_contents('rd-mailform.tpl'); if (isset($_POST['form-type'])) { switch ($_POST['form-type']){ case 'contact': $subject = 'A message from your site visitor'; break; case 'subscribe': $subject = 'Subscribe request'; break; case 'order': $subject = 'Order request'; break; default: $subject = 'A message from your site visitor'; break; } }else{ die('MF004'); } if (isset($_POST['email'])) { $template = str_replace( array("<!-- #{FromState} -->", "<!-- #{FromEmail} -->"), array("Email:", $_POST['email']), $template); }else{ die('MF003'); } if (isset($_POST['message'])) { $template = str_replace( array("<!-- #{MessageState} -->", "<!-- #{MessageDescription} -->"), array("Message:", $_POST['message']), $template); } preg_match("/(<!-- #{BeginInfo} -->)(.|\n)+(<!-- #{EndInfo} -->)/", $template, $tmp, PREG_OFFSET_CAPTURE); foreach ($_POST as $key => $value) { if ($key != "email" && $key != "message" && $key != "form-type" && !empty($value)){ $info = str_replace( array("<!-- #{BeginInfo} -->", "<!-- #{InfoState} -->", "<!-- #{InfoDescription} -->"), array("", ucfirst($key) . ':', $value), $tmp[0][0]); $template = str_replace("<!-- #{EndInfo} -->", $info, $template); } } $template = str_replace( array("<!-- #{Subject} -->", "<!-- #{SiteName} -->"), array($subject, $_SERVER['SERVER_NAME']), $template); $mail = new PHPMailer(); $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = ''; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = ''; // SMTP username $mail->Password = ''; // SMTP password $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted $mail->Port = 587; $mail->setFrom('', ''); $mail->addAddress('', 'Information Center'); // Add a recipient $mail->addReplyTo('', 'Information'); foreach ($addresses[0] as $key => $value) { $mail->addAddress($value[0]); } $mail->CharSet = 'utf-8'; $mail->Subject = $subject; $mail->MsgHTML($template); if (isset($_FILES['attachment'])) { foreach ($_FILES['attachment']['error'] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $mail->AddAttachment($_FILES['attachment']['tmp_name'][$key], $_FILES['Attachment']['name'][$key]); } } } $mail->send(); die('MF000'); } catch (phpmailerException $e) { die('MF254'); } catch (Exception $e) { die('MF255'); } ?> 我尝试添加以下代码,但所有电子邮件都会进入垃圾邮件文件夹。如何解决问题? if ($mail->send()){ require_once('./phpmailer/class.phpmailer.php'); $mail = new PHPMailer(); $mail->Host = ''; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = ''; // SMTP username $mail->Password = ''; // SMTP password $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted $mail->Port = 587; $mail->setFrom('[email protected]'); $to = $_POST['email']; $subject = 'Thanks for contacting us'; $msg = 'Hello, thanks for contacting us'; mail($to, $subject, $msg); } 这是我的问题: 1)我上面的代码可以工作,但是邮件将进入垃圾邮件文件夹(就在自动回复部分)。案件如何破案? 问候 $mail->setFrom('[email protected]'); $to = $_POST['userEmail']; $subject = 'Thanks for Contacting Us!'; $msg = 'Hi! Thanks for contacting us!'; mail($to, $subject, $msg); 上面是我如何编辑启动此线程的代码的自动回复部分。自动回复测试成功!但是,[电子邮件受保护] 不会显示在“发件人”区域中。仅显示服务器电子邮件地址。有什么建议么?谢谢! :--)

回答 1 投票 0

为什么我的 PHPmailer 无法将代码发送到提供的电子邮件

我有我的 Connect.php 正在处理注册 ` 我的 Connect.php 正在处理注册 ` <?php error_reporting(E_ALL); ini_set('display_errors', 1); session_start(); function generateVerificationCode() { return substr(md5(uniqid(mt_rand(), true)), 0, 6); // Generates a 6-character alphanumeric verification code } if (isset($_POST["submitSignUp"])) { // Check if captcha response is provided if (empty($_POST['g-recaptcha-response'])) { $_SESSION['error_message5'] = "re-CAPTCHA verification failed. Please try again"; header("Location: login.php"); // Redirect back to the signup page exit(); } // Verify captcha response $captchaResponse = $_POST['g-recaptcha-response']; $secretKey = '6LcqbYkpAAAAAIgIDMA849mdEbkYifGcw0Tk1_Ww'; // Replace with your secret key $captchaVerify = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret={$secretKey}&response={$captchaResponse}"); $captchaVerify = json_decode($captchaVerify); $emailAddress = $_POST['emailAdd']; $firstName = $_POST['firstName']; $lastName = $_POST['lastName']; $password = $_POST['password']; $confirmPassword = $_POST['confirmPassword']; $phoneNum = $_POST['phoneNum']; $registeredAt = date('Y-m-d'); // Validate that the password and confirm password match if ($password !== $confirmPassword) { $_SESSION['error_message4'] = "Password does not match. Please try again"; header("Location: login.php"); // Redirect back to the signup page exit(); } // Hash the password $passwordHash = password_hash($password, PASSWORD_DEFAULT); // Establish database connection $conn = new mysqli('localhost', 'root', '', 'database'); if ($conn->connect_error) { die('Connection Failed: ' . $conn->connect_error); } else { // Check if the email address already exists in the database $checkQuery = $conn->prepare("SELECT COUNT(*) FROM registration WHERE emailAdd = ?"); $checkQuery->bind_param("s", $emailAddress); $checkQuery->execute(); $checkResult = $checkQuery->get_result(); $count = $checkResult->fetch_assoc()['COUNT(*)']; if ($count > 0) { $_SESSION['error_message3'] = "Email address already exists."; header("Location: login.php"); // Redirect back to the signup page exit(); } // Ensure $registeredAt is not null if ($registeredAt === null) { $registeredAt = date('Y-m-d'); } // Generate verification code $verificationCode = generateVerificationCode(); // Store verification code in the database $verificationQuery = $conn->prepare("INSERT INTO email_verification (email, verification_code) VALUES (?, ?)"); $verificationQuery->bind_param("ss", $emailAddress, $verificationCode); $verificationQuery->execute(); $verificationQuery->close(); // Insert user data into the registration table $stmt = $conn->prepare("INSERT INTO registration (emailAdd, firstname, lastname, password, phonenum, registeredat) VALUES (?, ?, ?, ?, ?, ?)"); $stmt->bind_param("ssssss", $emailAddress, $firstName, $lastName, $passwordHash, $phoneNum, $registeredAt); if ($stmt->execute()) { // After successful registration, redirect and display success message $_SESSION['email_verification_address'] = $emailAddress; $_SESSION['success_message'] = "Code has been sent to your email."; header("Location: emailformverifyer.php"); exit(); } else { $_SESSION['error_message'] = "Registration failed. Please try again."; header("Location: login.php"); // Redirect back to the signup page exit(); } } } ` 当我提交生成的代码时,它位于数据库中,而我修改它的时间是当我将其放在验证器上时接受代码 但这一次我发送电子邮件时它不起作用(我认为它起作用,但由于我的 verify.php 没有通过电子邮件发送代码而失败(“发送电子邮件失败:电子邮件地址格式无效。”)) 这是我的Verify.php,处理将发送到电子邮件的代码 ` <?php session_start(); use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; require_once __DIR__ . '/vendor/autoload.php'; // Create an instance of PHPMailer $mail = new PHPMailer(true); error_reporting(E_ALL); ini_set('display_errors', 1); // Check if the form is submitted if ($_SERVER["REQUEST_METHOD"] === "POST") { // Retrieve the email address and verification code from the form $emailAddress = isset($_POST['emailAdd']) ? $_POST['emailAdd'] : ''; $verificationCode = isset($_POST['verification_code']) ? $_POST['verification_code'] : ''; // Validate the email address format if (!filter_var($emailAddress, FILTER_VALIDATE_EMAIL)) { $_SESSION['email_sent_error'] = 'Failed to send email: Invalid email address format.'; header("Location: login.php"); exit(); } try { // Compose the email $mail->isSMTP(); $mail->Host = 'localhost'; // Your SMTP host $mail->SMTPAuth = true; $mail->Username = '[email protected]'; // Your SMTP username $mail->Password = 'secret'; // Your SMTP password $mail->SMTPSecure = 'tls'; $mail->Port = 25; // Your SMTP port $mail->SMTPDebug = SMTP::DEBUG_CONNECTION; $mail->setFrom('[email protected]', 'Gemma Balnodo'); $mail->addAddress($emailAddress); // Add the recipient email address $mail->Subject = 'Email Verification'; $mail->Body = 'Here is your verification code: ' . $verificationCode . '. Click <ahref="emailformverifyer.php">here</a> to verify.'; // Send the email if ($mail->send()) { // Email sent successfully $_SESSION['email_sent_success'] = true; header("Location: verification_form.php"); exit(); } else { // Failed to send email $_SESSION['email_sent_error'] = 'Failed to send email: ' . $mail->ErrorInfo; header("Location: login.php"); exit(); } } catch (Exception $e) { $_SESSION['email_sent_error'] = 'Failed to send email: ' . $e->getMessage(); header("Location: login.php"); exit(); } }` 您正在将 $_SESSION['email_verification_address'],而不是 $_POST['emailAdd'] 传递给您的Verify.php 所以改变 if ($_SERVER["REQUEST_METHOD"] === "POST") { // Retrieve the email address and verification code from the form $emailAddress = isset($_POST['emailAdd']) ? $_POST['emailAdd'] : ''; 到 if ($_SESSION['email_verification_address'] !="") { // Retrieve the email address and verification code from the form $emailAddress = isset($_SESSION['email_verification_address']) ? $_SESSION['email_verification_address'] : '';

回答 1 投票 0

Sendgrid PHP 文件附件 0KB

使用下面的内容,我可以将附件添加到来自 $_FILES 帖子的电子邮件中,但是它们的附件大小为 0kb / null。 名称和内容类型似乎没有问题?想知道是否有人可以...

回答 1 投票 0

Sendgrid PHP / PHPMailer - 附件未添加到电子邮件

我使用下面的代码来获取并将我的文件输入文件上传到服务器位置。我没有错误,但是附件在发送时没有添加到电子邮件中? 这是我的代码: 超文本标记语言 我使用下面的代码来获取并将我的文件输入文件上传到服务器位置。我没有错误,但是附件在发送时没有添加到电子邮件中? 这是我的代码: HTML <input type="file" name="fileinput_name" id="fileinput_name"/> PHP if (array_key_exists('fileinput_name', $_FILES)) { $uploadfile = move_uploaded_file($_FILES["fileinput_name"]["tmp_name"],"uploadtmp/" . $_FILES["fileinput_name"]["name"]); if (move_uploaded_file($_FILES['fileinput_name']['tmp_name'], $uploadfile)) { // Attach the uploaded file $fileinputname = "uploadtmp/" . $_FILES["fileinput_name"]["name"]; $mail->addAttachment($uploadfile, $fileinputname); } } 邮件发送成功,PHP 日志中没有错误。 另外,如果有人有一种在邮件发送后删除文件的方法,或者我可以在根本不上传到服务器的情况下实现此目的的方法,那就太好了? 我已经尝试过这些标记的答案,但仍然无法附加到邮件: phpMailer 附件不起作用 在 phpmailer 中添加附件的语法是 addAttachment($path,$name); 例如 $mail->addAttachment('uploads/image.jpg', 'new.jpg'); 对于您的情况, $uploadfile 是 move_uploaded_file 函数的轮次,这不是实际路径。 所以改变 $mail->addAttachment($uploadfile, $fileinputname); 到 $mail->addAttachment($fileinputname , $_FILES["fileinput_name"]["name"]);

回答 1 投票 0

我正在尝试使用 php-mailer 将列表取消订阅标头添加到我的电子邮件标头

我想在 Gmail、yahoo 和 Outlook 等电子邮件提供商的电子邮件标题旁边显示取消订阅链接。 这就是它在 PHP-mailer 中的调用方式:(我已经通过以下方式尝试过) 第一种方式: $邮件->

回答 1 投票 0

PHPMailer Sendgrid PHP - DomPDF HTML 渲染附件

我试图通过以下代码附加 dompdf 文件而不保存到服务器: 我从 PHP 响应中得到的错误是:无法发送消息。邮件程序错误:未知编码:pdffilename....

回答 1 投票 0

如何在ubuntu中安装邮件客户端?

我在尝试安装一些邮件客户端(如 Squirrel 或 postfix)时遇到很多问题... 我尝试安装邮件客户端,但收到很多失败信息,例如无法连接 smtp 服务器或类似服务器,以及

回答 1 投票 0

PHPMailer 忽略

我目前收到的使用纯文本/文本电子邮件从 PHPMailer 发送的电子邮件存在问题。我目前正在通过获取行并保存来从数据库返回电子邮件......

回答 6 投票 0

GMAIL 在使用 file_get_contents 时显示消息被剪裁

当使用 PHPmailer 发送电子邮件时,我已切换为使用 HTML 模板。执行此操作后,我在 GMAIL 中收到一条消息,指出 [消息已剪辑] 查看整个消息 在故障排除中我有

回答 2 投票 0

PHPmailer 发送邮件两次

此脚本会导致电子邮件发送两次(并非总是如此)。我读到这可能是浏览器的故障,所以我在没有扩展的情况下运行 chrome。还是一样.. 主题行包含...

回答 1 投票 0

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