[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 972
  • Last Modified:

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.
0
m2ew
Asked:
m2ew
  • 3
  • 3
1 Solution
 
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
 
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
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
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
 
rationalbossCommented:
$p = new PHPMailer();
$p->MailerDebug = false;

or just edit phpmailer.inc.php and change MailerDebug's default value to false
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now