使用PHP的Mailgun
我一直在尝试使用PHP编码的Mailgun实现一个联系人服务。我收到以下错误: 下面是我的代码:使用PHP的Mailgun,php,phpmailer,mailgun,Php,Phpmailer,Mailgun,我一直在尝试使用PHP编码的Mailgun实现一个联系人服务。我收到以下错误: 下面是我的代码: <?php require("../includes/config.php"); require("../mailgun-php/vendor/autoload.php"); require("../phpmailer/_lib/class.phpmailer.php"); use Mailgun\Mailgun; if($_SERVER["REQUEST_METHOD"] === "G
<?php
require("../includes/config.php");
require("../mailgun-php/vendor/autoload.php");
require("../phpmailer/_lib/class.phpmailer.php");
use Mailgun\Mailgun;
if($_SERVER["REQUEST_METHOD"] === "GET")
{
render("contact-form.php", ["title" => "Contact us"]);
}
if($_SERVER["REQUEST_METHOD"] === "POST")
{
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.mailgun.org'; // Specify mailgun SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'postmaster@sandboxb9cc446d8b7240efa59917c68fae6e50.mailgun.org'; // SMTP username from https://mailgun.com/cp/domains
$mail->Password = '*SMTP password from sandbox domain'; // SMTP password from https://mailgun.com/cp/domains
$mail->SMTPSecure = 'sll'; // Enable encryption, 'ssl'
$mail->Port= '465';
$mail->From = 'sandboxb9cc446d8b7240efa59917c68fae6e50.mailgun.org'; // The FROM field, the address sending the email
$mail->FromName = 'Enquiry bot'; // The NAME field which will be displayed on arrival by the email client
$mail->addAddress('****@gmail.com'); // Recipient's email address and optionally a name to identify him
$mail->isHTML(true); // Set email to be sent as HTML, if you are planning on sending plain text email just set it to false
// The following is self explanatory
$mail->Subject = 'Client enquiry';
$mail->Body = $_POST["message"];
if(!$mail->send())
{
echo "Message hasn't been sent.";
echo 'Mailer Error: ' . $mail->ErrorInfo . "\n";
}
else
{
redirect("confirmation.html");
}
}
?>
我已经联系了邮枪工作人员,他们为我提供了极好的支持。问题在于如何指定端口。SSL的密码应为465,TLS的密码应为587。您是否已在服务器上连接到smtp,并验证服务是否正在运行,以及您是否可以使用该密码进行连接?很抱歉,我对smtp的经验和知识非常有限。我怎么能这么做?要添加更多信息,我正在运行一个WAMP虚拟主机服务器。您需要搜索该消息-此问题有许多重复项。你也应该阅读文档,告诉你如何处理它。谢谢你的信息!我会尽快调查的。