Solved

PHP Mailer - SMTP Error

Posted on 2011-03-01
7
958 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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 …

762 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now