wordpress using class.phpmailer.php in script

Posted on 2011-10-20
Last Modified: 2012-05-12

Don't you just love the way wordpress hides all the error messages so you can't see what is going wrong?!

I am trying to create my own contact form, and has some assistance a little earlier...  A bit of background, I want to use my own php/jquery script to validate/process the form and I have used the script from one of my existing sites (which works perfecto)

I have got as far as validating the form and getting to the point where it is ready to send the form to an email address.

to do this I am using class.phpmailer.php, which I am requiring via php

the class appears to be loaded as I can successfully initiate it as follows:

$mail = new PHPMailer();

however, all of the code executes until the $mail->send(); call

I cant see what the error is because wordpress is hiding it, any ideas what could be going wrong?


$mail = new PHPMailer();
			$mail->Host     = "";
			$mail->Mailer   = "smtp";
			$mail->SMTPAuth = "true";
			$mail->Username = "";
			$mail->Password = "****";
			$mail->From= $email;
			$mail->Subject = "Website Enquiry " . $subject;

			$mail->Body = $message;
			$mail->AltBody= $mess; 

Open in new window

Question by:cycledude
    LVL 70

    Accepted Solution

    Cycle dude,

    Wordpress hides errors on purpose.  You can enable debug mode to view and/or log.

    So after enabling debug mode, what do you see when the script is called?

    Author Comment

    hi jason

    I have juust worked out how to enable debug mode

    define('WP_DEBUG', true);

    thanks... I am looking at whats going wrong now... so much easier when you can see errors!

    LVL 70

    Expert Comment

    by:Jason C. Levine
    It really is.  But always remember that Wordpress is aimed at the end users who tend to have unreasonable reactions to things like warnings or errors. So the Dev team thoughtfully hid them.  Of course, those of us who need those things also can't see them :)

    Getting it back is simple enough and if you really dig, there are plugins that will do all sorts of logging and reveal all sorts of stuff that goes on under the hood.  Worth investigating if you are going to spend any time at all under the hood.

    Author Comment

    thanks fellas, jason you are right... there are a frightening number of warnings that are being hidden! lol


    Author Closing Comment

    hurrah, once I could see what the error was I was able to right it...
    in my case, the class.phpmailer.php was unable to locate both the pop3 and smtp class files it needed, once this was sorted it worked.

    happy days!
    LVL 70

    Expert Comment

    by:Jason C. Levine
    Awesome! By my count, you've more or less solved your last two questions yourself.  When do we get to see you start answering alongside us and earn the free membership?

    Author Comment


    lol, yep I usually find it easier to answer after I have typed in the question!...

    I don't mind paying, this site is a great resource for me, as I have so many questions!


    Featured Post

    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!

    Join & Write a Comment

    In Part I (, I introduced you to the powerful WordPress backend, the WordPress administrative Dashboard.  In Part II, I will introduce yo…
    I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

    731 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

    15 Experts available now in Live!

    Get 1:1 Help Now