我整天都在为此苦苦挣扎。服务器过去可以在没有 smtp 身份验证的情况下工作。现在它没有了。所以我创建了一个邮件地址,将填写好的脚本转发到我的电子邮件地址。我曾经得到错误。现在我不再收到任何错误,但我仍然没有收到任何邮件。
也许你们可以看看我的代码是否有问题。
require_once "Mail.php";
$recipient = "mwmhermans@outlook.com"; //Het email adres van de persoon die vragen moet ontvangen.
$subject = "Dealership request." + $_POST['naam']; //Subject van de mail.
$header = "From: " . $_POST['email'] . "\n";
$mail_body = "Contact script was executed on " . date("d-m-Y") . " at " . date("H:i") . " \n"; // tijd van uitvoering
$mail_body .= "The following person executed the script:\n\n";
$mail_body .= "Name: " . $_POST['naam'] . "\n";
$mail_body .= "E-mail: " . $_POST['email'] . "\n\n";
$mail_body .= "Company: " . $_POST['company'] . "\n";
$host = "";
$username = "";
$password="";
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($recipient, $subject, $header, $body);
echo '<div style="margin-left:25px;"><div class="wrapper">';
echo "<br/><b>Your request is successfully sent.</b><br>You'll get a response as soon as possible.</b><br>";
echo "<a class=\"main\" href='javascript:history.back(1)'>Back</a>";
echo '</div></div>';