Solved

PHP Mailer - SMTP Error

Posted on 2011-03-01
7
961 Views
Last Modified: 2012-05-11
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
Comment
Question by:m2ew
  • 3
  • 3
7 Comments
 
LVL 16

Expert Comment

by:Enphyniti
ID: 35010422
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
 

Author Comment

by:m2ew
ID: 35010440
Yes, It is sending an email. I want to turn if off on fail, and dump it into a session variable.
0
 
LVL 16

Expert Comment

by:Enphyniti
ID: 35010485
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:m2ew
ID: 35010760
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
 
LVL 16

Expert Comment

by:Enphyniti
ID: 35011340
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
 

Author Comment

by:m2ew
ID: 35011562
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
 
LVL 8

Accepted Solution

by:
rationalboss earned 150 total points
ID: 35013290
$p = new PHPMailer();
$p->MailerDebug = false;

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

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP AJAX JSON 2 60
google analytics in wordpress 4 34
PHP Installer 5 23
How would I do this...? 2 28
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
A phishing scam that claims a recipient’s credit card details have been “suspended” is the latest trend in spoof emails.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question