我做错了什么。有一个html表单,它有三个输入Name,Notes和Phone。表单上的操作是mail.php,方法是POST。
这是mail.php中的代码。成功后,我希望它返回主页。
<?php
// multiple recipients
//$to = 'waleed.dogar@gmail.com' . ', '; // note the comma
error_reporting(E_STRICT);
date_default_timezone_set('America/Toronto');
require_once('/phpmailer/class.phpmailer.php');
require_once('/phpmailer/class.smtp.php');
$mail = new PHPMailer();
$mail->Subject = 'Form Submission on Website';
$name = $_REQUEST['name'] ;
$notes = $_REQUEST['notes'] ;
$phone = $_REQUEST['phone'] ;
$body = "You have received a new message from $name.\n". "Here is the phone number:\n $phone". "Here are the additional notes: \n $notes";
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "smtpout.secureserver.net"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "smtpout.secureserver.net"; // sets the SMTP server
$mail->Port = 80; // set the SMTP port for the GMAIL server
$mail->Username = "alex@acemobiledetailing.ca"; // SMTP account username
$mail->Password = "password"; // SMTP account password
$mail->SetFrom('example@example.ca', 'Alex Website');
$mail->AddReplyTo("example@example.ca","Alex ");
$mail->MsgHTML($body);
$address = "example@gmail.com";
$mail->AddAddress($address, $name);
$mail-> Send();
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
GOTO(http://example.com/thankyou.php);
}
?>