我对 php 一无所知,但几乎没有帮助和研究,我设法用 Swift Mailer 建立了工作联系表。它可以发送消息,但我希望它在发送消息后将人们重定向到thank_you.html 页面。我尽我所能,但它不起作用。你可以帮帮我吗?这是代码:
<?php
include("Swift/lib/swift_required.php");
$host = 'xxxxxx.xxxxxx@gmail.com';
$password = 'xxxxx';
$subject = "zapytanie ze strony";
$body = "Zglaszajacy: ".$_POST["fullname"]."\r\n";
$body .= "Telefon: ".$_POST["phone"]."\r\n";
$body .= "E-mail: ".$_POST["email"]."\r\n";
$body .= "Tresc: ".$_POST["description"]."\r\n";
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')
->setUsername($host)
->setPassword($password);
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance($subject)
->setFrom(array($host => 'Klient'))
->setTo(array('xxxxxxx@xxxx.gmail.com'=> 'xxxxxx'))
->setBody($body);
$result = $mailer->send($message);
if ($result)
{
header('Location: http://www.xxxxx.org/thank_you.html');
}
echo $result;
?>
我自己添加了那部分:
if ($result)
{
header('Location: http://www.xxxxx.org/thank_you.html');
}
它不起作用。邮件已发送,但表单没有任何反应。它只是停留在那里。请把我当作一个外行来对待;)