Jump to content

PHPMailer responses echoed to page


ChaosKnight

Recommended Posts

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.