我已經在PHP /電子郵件「地獄」 - 我接近,似乎並不能去的「終點線」 ....PHPMailer的,電子郵件的行爲神祕
嗡使用的PHPMailer發送支持在客戶端的請求。我的過程如下所示: FORM - > PROCESS(生成反饋消息和cc消息以支持) - >發送給發件人 - >支持郵件 - >重定向到感謝頁面。
的問題是雙重的: 1)電子郵件走通預期,如果我有調試運行開啓,但我得到的調試和不重定向 2)如果我關掉調試 - 的電子郵件不出去我得到一個空白頁 - 沒有重定向
*增編* 的電子郵件剛剛通 - 所以它只是一個重定向問題......有或沒有調試,我的元刷新不會發送 - 也許有更好的方法?
PHP表單處理
...
// send two emails
$_emailTo = $email; // the email of the person requesting
$_emailBody = $text_body; // the stock response with things filled in
include ('email.php');
$_emailTo = $notifyEmail; // the support email address
$_emailBody = $pretext.$text_body; // pretext added as meta data for support w/ same txt sent to user
include ('email.php');
// relocate
echo '<META HTTP-EQUIV="Refresh" Content="0; URL=success.php" >';
exit;
PHP郵件程序(email.php)
<?php
require 'phpmailer/class.phpmailer.php';
//Create a new PHPMailer instance
$mail = new PHPMailer();
//Tell PHPMailer to use SMTP
$mail->IsSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 0;
//Set the hostname of the mail server
$mail->Host = "mail.validmailserver.com";
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = 26;
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication
$mail->Username = "validusername";
//Password to use for SMTP authentication
$mail->Password = "pass1234";
//Set who the message is to be sent from
$mail->SetFrom('[email protected]', 'no-reply @ this domain');
//Set an alternative reply-to address
//$mail->AddReplyTo('[email protected]','Support');
//Set who the message is to be sent to
$mail->AddAddress($_emailTo);
$mail->Subject = $_emailSubject;
$mail->MsgHTML($_emailBody);
$_emailError = false;
//Send the message, check for errors
if(!$mail -> Send()) {
$_emailError = true;
echo "Mailer Error: " . $mail->ErrorInfo;
}
?>
幫助 - 請
有沒有辦法在PHP中抑制輸出? – jpmyob
是的,我編輯了我的答案,在php中包含有關輸出緩衝的一些信息。 – vjones