【发布时间】:2019-07-26 13:29:16
【问题描述】:
我正在使用联系表 7,但遇到此电子邮件 ID 的问题,我没有收到任何邮件,我们可以为此做些什么。我也使用了 SMTP。 你能建议我任何其他选择吗?
【问题讨论】:
标签: wordpress email contact-form-7
我正在使用联系表 7,但遇到此电子邮件 ID 的问题,我没有收到任何邮件,我们可以为此做些什么。我也使用了 SMTP。 你能建议我任何其他选择吗?
【问题讨论】:
标签: wordpress email contact-form-7
最好的选择是在 php 中使用 PhpMailer 库。您可以使用 php mailer 检查电子邮件是否发送成功。您需要做的就是获取所有库代码并将其添加到您的 FTP 或使用 composer 安装它。
这是一个简单的例子。
<?php
// 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\Exception;
// Load Composer's autoloader
require 'vendor/autoload.php';
// Instantiation and passing `true` enables exceptions
$mail = new PHPMailer(true);
try {
//Server settings
$mail->SMTPDebug = 2; // 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 = 'user@example.com'; // SMTP username
$mail->Password = 'secret'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
//Recipients
$mail->setFrom('from@example.com', 'Mailer');
$mail->addAddress('joe@example.net', 'Joe User'); // Add a recipient
$mail->addAddress('ellen@example.com'); // Name is optional
$mail->addReplyTo('info@example.com', 'Information');
$mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com');
// Attachments
$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
// 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';
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
您可以在这里Php Mailer On Github获取有关 PhpMailer 的所有信息
PhpMailer 配置良好,因此您不必担心您的电子邮件最终会进入垃圾邮件文件夹。还要注意定期发送给单个收件人的邮件数量。
【讨论】:
您检查过垃圾邮件文件夹吗?也许电子邮件在垃圾邮件中,因为电子邮件不在垃圾邮件中,您可以使用https://wordpress.org/plugins/wp-mail-smtp/
这里是设置文档https://wpforms.com/docs/how-to-set-up-smtp-using-the-wp-mail-smtp-plugin/。
请检查可能对您有帮助。
【讨论】: