2015-12-31 138 views
0

我有一個頁面通過使用HTML表單通過電子郵件發送圖像。它的功能很好,但是當用戶點擊發送電子郵件時,它會顯示send.php頁面後面的整個動作。我怎樣才能隱藏用戶。如果我可以在頁面上顯示「您的消息已發送!!!」的文本,這將是非常好的。不顯示PHP表單操作頁面

<form name="form1" method="post" action="email/send.php"> 
    <input type=button value="Take HD Snapshot" onClick="take_snapshot()"> 
    <input type="submit" name="Submit" value="Send Email"> 
</form> 

SEND.PHP如下。這是一個PHPMAILER插件。

<?php 
/** 
* This example shows settings to use when sending via Google's Gmail servers. 
*/ 
//SMTP needs accurate times, and the PHP time zone MUST be set 
//This should be done in your php.ini, but this is how to do it if you don't have access to that 
date_default_timezone_set('Etc/UTC'); 
require 'PHPMailerAutoload.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 = 1; 
//Ask for HTML-friendly debug output 
$mail->Debugoutput = 'html'; 
//Set the hostname of the mail server 
$mail->Host = 'mail_server'; 
// use 
// $mail->Host = gethostbyname('mail_server'); 
// if your network does not support SMTP over IPv6 
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission 
$mail->Port = 587; 
//Set the encryption system to use - ssl (deprecated) or tls 
$mail->SMTPSecure = 'tls'; 
//Whether to use SMTP authentication 
$mail->SMTPAuth = true; 
//Username to use for SMTP authentication - use full email address for gmail 
$mail->Username = "username"; 
//Password to use for SMTP authentication 
$mail->Password = "password"; 
//Set who the message is to be sent from 
$mail->setFrom('username', 'Name'); 
//Set an alternative reply-to address 
$mail->addReplyTo('Name', 'Name'); 
//Set who the message is to be sent to 
$mail->addAddress('Name', 'Name'); 
//Set the subject line 
$mail->Subject = 'PHPMailer GMail SMTP test'; 
//Read an HTML message body from an external file, convert referenced images to embedded, 
//convert HTML into a basic plain-text alternative body 
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__)); 
//Add an Attachment 
$mail->AddAttachment("../snapshots/image.jpg"); 
//Replace the plain text body with one created manually 
$mail->AltBody = 'This is a plain-text message body'; 
//send the message, check for errors 
if (!$mail->send()) { 
    echo "Mailer Error: " . $mail->ErrorInfo; 
} else { 
    echo "Message sent!"; 
} 
?> 
+0

您可以使用AJAX發送郵件。在AJAX響應中,您可以顯示成功消息。 – Pupil

+0

什麼在send.php?並沒有你不需要AJAX –

+1

請編輯您的問題,包括相關的PHP代碼。您可以從php代碼中刪除不需要的輸出 – Tristan

回答

1

的解決方案是改變PHPMailer的爲不包括調試

$ MAIL-> SMTPDebug = 0; (它是1)