我设置了一个使用PHPMailer发送的电子邮件。它按原样发送,但是,我希望在脚本完成后将用户重定向到页面。到目前为止它只是在完成时说bool(true)。这是我的代码:
if(isset($_POST['submit'])) {
$dName = $_POST['dName'] ;
$dAddress = $_POST['dAddress'] ;
$phone = $_POST['phone'] ;
$cName = $_POST['cName'] ;
$cEmail = $_POST['cEmail'] ;
$departure = $_POST['departure'] ;
$rooms = $_POST['rooms'] ;
$attendee1 = $_POST['attendee1'] ;
$attendee2 = $_POST['attendee2'] ;
$transportation = $_POST['transportation'] ;
$file = $_POST['uploaded_file'] ;
$requests = $_POST['requests'] ;
require_once 'libs/PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
if (isset($_FILES['uploaded_file']) &&
$_FILES['uploaded_file']['error'] == UPLOAD_ERR_OK) {
$mail->AddAttachment($_FILES['uploaded_file']['tmp_name'],
$_FILES['uploaded_file']['name']);
}
$mail->From = 'me@example.com';
$mail->FromName = '20th Registration';
$mail->addReplyTo('reply@example.com', 'Reply TO');
$mail->addAddress('send@example.com', 'Sending TO');
$mail->addBCC('bcc@example.com', 'HIDING');
$mail->Subject = 'Fort Wayne Dealer Registration';
$mail->Body = '<strong>Dealer Name: </strong>' . $dName . '<br/>
<strong>Dealer Address: </strong>' . $dAddress . '<br/>
<strong>Phone Number: </strong>' . $phone . '<br/>
<strong>Contact Person: </strong>' . $cName . '<br/>
<strong>Contact Email: </strong>' . $cEmail . '<br/>
<strong>Departure Day: </strong>' . $departure . '<br/>
<strong>Number of Rooms: </strong>' . $rooms . '<br/>
<strong>Attendee 1: </strong>' . $attendee1 . '<br/>
<strong>Attendee 2: </strong>' . $attendee2 . '<br/>
<strong>Transportation: </strong>' . $transportation . '<br/>
<strong>Special Requests: </strong>' . $requests . '<br/>';
$mail->AltBody = 'This is the alt body of the email';
var_dump($mail->send());
问题是如果我删除var_dump($ mail-&gt; send()),这将不会发送; 我想用:
if ($mail->Send()) {
echo "worked";
} else {
echo "failed: " . $mail->ErrorInfo;
}
我在这里缺少什么?