PHP Mailer - SMTP Error

Hi I'm running a php mailer email. When there is an SMTP error the error message is breaking my layout.

SMTP Error: The following recipients failed: testtest@email.com

Is there anyway to hide this message when the email executes? I would rather move it into a session object that I can call in different sections of my php templates.
m2ewAsked:
Who is Participating?
 
rationalbossConnect With a Mentor Commented:
$p = new PHPMailer();
$p->MailerDebug = false;

or just edit phpmailer.inc.php and change MailerDebug's default value to false
0
 
Jon BrelieSystem ArchitectCommented:
Does it send any email, or do all addresses fail?

If I understand your question correctly, you are only trying to suppress the error returned when you use an invalid address.  Correct?
0
 
m2ewAuthor Commented:
Yes, It is sending an email. I want to turn if off on fail, and dump it into a session variable.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Jon BrelieSystem ArchitectCommented:
Assuming you are doing a mail($to, $subject... etc... I think you can just change it to:

@mail($to, $subject.. etc...

Otherwise if you want to do fancy error handling, you could do something like what is outlined here:  

http://stackoverflow.com/questions/4798498/disable-phpmailer-error-messages
0
 
m2ewAuthor Commented:
I tried the stack overflow method. The error output worked for putting the error info a new object that I can call in the template. However the SMTP error is still appearing.

Other than commenting it out of the PHPMailer class is there another way to disable?
0
 
Jon BrelieSystem ArchitectCommented:
You might try experimenting with ini_set() and try either of the following:

error_reporting(0)
or
display_errors(stderr)

More reading:
http://us.php.net/manual/en/errorfunc.configuration.php#ini.error-reporting
0
 
m2ewAuthor Commented:
From what I've tried it the display_errors won't block any fatal script errors, such as the SMTP recipient error that PHP Mailer is generating.

For now I'll create another instance and comment out the echo in PHP Mailer.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.