rosceoh
rosceoh

Reputation: 15

disable phpmailer error messages

When I send the mail I am getting the error messages on the screen, things like...

> Invalid address:  Invalid address:
> 423Invalid address: 423

How can I switch this off?

Thanks,

R.

Upvotes: 1

Views: 3731

Answers (4)

Patrick
Patrick

Reputation: 1

Throw errors is ok, but if you intend to catch the (error) result and map it into an own result (e.g. you want to create an json result) you'll get a problem with these html outputs.

Upvotes: -2

Ubaldo
Ubaldo

Reputation: 21

I had the same problem and fixed it commenting the line that have the echo that displays the error.

if (!self::ValidateAddress($address)) {
  $this->SetError($this->Lang('invalid_address').': '. $address);
  if ($this->exceptions) {
    throw new phpmailerException($this->Lang('invalid_address').': '.$address);
  }
  //echo $this->Lang('invalid_address').': '.$address; <----- COMMENT THIS LINE (LINE 464)
  return false;
}

After this, even that the address is invalid, the message is not displayed.

by Tronks

Upvotes: 2

Notopic
Notopic

Reputation: 82

Add the following setting.

$mail->SMTPDebug = false;
$mail->do_debug = 0;

Upvotes: 3

Trufa
Trufa

Reputation: 40717

With the amount of information we have from the question I'm not sure the answer is correct but, when you put the @ sign before the mail function.

@mail($to, $subject, $message, $headers);

Suppreses the errors, but you h¡should hide errors for "sticking your head under the sand", this should be done to avoid ugly/unfriendly erros etc, you shouldn't hide from your errors.

Upvotes: 1

Related Questions