1

我整天都在为此苦苦挣扎。服务器过去可以在没有 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>'; 
4

1 回答 1

1

我认为,您设置的参数不正确send。正如手册页所说,概要是:

mixed send ( mixed $recipients , array $headers , string $body )

当你这样称呼它时:

send(mixed $recipient, string $subject, string $header, string $body);

请查看该页面上的示例并根据它更改您的代码。

于 2013-09-30T16:50:36.853 回答