我已经在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