我整天都在苦苦挣扎。服务器过去没有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>';
答案 0 :(得分:1)
我认为,您正在为send
功能设置不正确的参数。正如manual page所说,概要是:
mixed send ( mixed $recipients , array $headers , string $body )
虽然你这样称呼它:
send(mixed $recipient, string $subject, string $header, string $body);
请查看该页面上的示例并根据它更改您的代码。