ChaosKnight Posted May 14, 2010 Share Posted May 14, 2010 Okay, so I finally got PHPMailer to work, but now whenever I send an email, a whole bunch of server responses are echoed to the page. How can I hide this server responses? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/201811-phpmailer-responses-echoed-to-page/ Share on other sites More sharing options...
kenrbnsn Posted May 15, 2010 Share Posted May 15, 2010 Please post your code. What do you mean by "server responses"? Post a sample. Ken Quote Link to comment https://forums.phpfreaks.com/topic/201811-phpmailer-responses-echoed-to-page/#findComment-1058614 Share on other sites More sharing options...
ChaosKnight Posted May 15, 2010 Author Share Posted May 15, 2010 Here is the PHP code that is above the contact form, which runs when the submit button is pressed: <?php if (isset($_POST['submit'])){ require_once "PHPMailer/class.phpmailer.php"; // Database works fine, so I left out that code... if(mysql_query($sql,$link)){ $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = 'mail.domain'; $mail->SMTPAuth = true; $mail->Username = 'username'; $mail->Password = 'password'; $mail->From = 'from address'; $mail->SMTPDebug = true; $mail->AddReplyTo($email, $name); $mail->FromName = 'from <address>'; $mail->AddAddress('to address', 'name'); $mail->Subject = $subject; $mail->MsgHTML($message); $mail->AltBody=$message; if(!$mail->Send()){ echo "<h3>The message was not sent...</h3>"; }else{ echo "<h3>The message was sent successfully...</h3>"; } } mysql_close($db_link); } ?> When the above code is executed, the email is delivered successfully, but server responses are posted directly above the form, and this is not the desired result seeing that this is a contact form for people who visit the site. Here is some of the "server responses" that are displayed: SMTP -> get_lines(): $data was "" SMTP -> get_lines(): $str is "220, etc... And it ends with: 250 Message queued SMTP -> get_lines(): $data was "" SMTP -> get_lines(): $str is "221 Goodbye " SMTP -> get_lines(): $data is "221 Goodbye " SMTP -> FROM SERVER: 221 Goodbye I tried to find this lines in the page source that is recieved in the browser, but I can't find it, so it's not just some HTML, so I figured that it's server responses... But why is it showing above the form each time an email is submitted? Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/201811-phpmailer-responses-echoed-to-page/#findComment-1058647 Share on other sites More sharing options...
PFMaBiSmAd Posted May 15, 2010 Share Posted May 15, 2010 Comment out or otherwise remove the following line of code - $mail->SMTPDebug = true; Quote Link to comment https://forums.phpfreaks.com/topic/201811-phpmailer-responses-echoed-to-page/#findComment-1058698 Share on other sites More sharing options...
ChaosKnight Posted May 15, 2010 Author Share Posted May 15, 2010 Thanks! Problem SOLVED! Quote Link to comment https://forums.phpfreaks.com/topic/201811-phpmailer-responses-echoed-to-page/#findComment-1058704 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.