I have written an email contact form in php. I am using the Pear Mail package to send the email. It works nicely on my development computer, but not on the server. Here is the code:
//////////////////////////////////////////////////
// EMAIL OPTIONS
//////////////////////////////////////////////////
$to = "[email protected]";
$subject = "Contact Form Submission";
$smtphost = "localhost";
$port = "25";
$authenticate = false;
$username = "smtp_username";
$password = "smtp_password";
// create and send the email
$from = $_POST['fullname'] . " <" . $_POST['email'] . ">";
$body = str_replace($ph, $rv, $emailTemplate);
$headers = array (
'MIME-Version' => '1.0',
'Content-type' => 'text/html; charset=iso-8859-1',
'From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $smtphost,
'port' => $port,
'auth' => $authenticate,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
$error = PEAR::isError($mail);
if ($error){
echo 'An error occurred.';
}
else {
require('thanks.php');
exit;
}
I don't know why it's failing on the server. How can I get some more useful information out of my $error object?
Echoing $error results with
1