Support » How-To and Troubleshooting » Sending Mail via PEAR

Sending Mail via PEAR

  • Hi,

    I just developed a custom theme and installed WordPress at the root of my site.

    Before this I had a collection of static html pages. One of the features I had was a jQuery plugin which opens a ‘contact me’ form to let visitors send me an email directly from my site. It used a simple PHP file that used the PEAR extension to send the email to my hotmail. It was simple but it worked well and I got the emails.

    After installing wordpress and my custom theme however the emailer no longer works. Even though I have the same PHP file, in the same locations on my server, the emails are not being sent to me.

    This is the PHP file:

    	require_once "Mail.php";
    	$to = "my_email_address";
    	$from = $_POST["from"];
    	$subject = $_POST["subject"];
    	$body = $_POST["message"] . "\n\n" . $_POST["pageURL"];	
    	$host = "localhost";
    	$username = "my_correct_verified_username";
    	$password = "my_correct_verified_password";
    	$headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject);
    	$smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password));
    	$mail = $smtp->send($to, $headers, $body);
    	if (PEAR::isError($mail)) {
     	} else {
      		echo("Message successfully sent!");

    Any idea why this would stop working after intalling WP? Is it to do with the script not being able to find Mail.php in the require_once line?

Viewing 3 replies - 1 through 3 (of 3 total)
  • My host support desk said it might be something to do with wordpress htaccess files rewriting URLs? Could this be the case?

    It is finding the sendMail.php file ok because if I change the hostname in that file it gives an error.

    Could it be that it can’t find Mail.php or the PEAR extension maybe?

    Ok, it definitely seems to be a rewrite error as the request is being made to the root of my site instead of to the PHP file…

    Does no one really have any ideas on this?

    I don’t think this would be a rewrite error. I would say that it can’t find the Mail.php file. Do you have the sendMail.php file in the same directory as Mail.php?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Sending Mail via PEAR’ is closed to new replies.