phpmailer error "Could not instantiate mail function"


I'm using the mail() basic example modified slightly for my user id and I'm getting the error "Mailer Error: Could not instantiate mail function"

if I use the mail function -

mail($to, $subject, $message, $headers);

it works fine, though I'm having trouble sending html, which is why I'm trying PHPMailer.

this is the code:


    $mail             = new PHPMailer(); // defaults to using php "mail()"
    $body             = file_get_contents('contents.html');
    $body             = eregi_replace("[\]",'',$body);
        print ($body ); // to verify that I got the html
    $mail->AddReplyTo("","my name");
    $mail->SetFrom('', 'my name');
    $address = "";
    $mail->AddAddress($address, "her name");
    $mail->Subject    = "PHPMailer Test Subject via mail(), basic";
    $mail->AltBody    = "To view the message, please use an HTML compatible email viewer!";
    $mail->AddAttachment("images/phpmailer.gif");      // attachment
    $mail->AddAttachment("images/phpmailer_mini.gif"); // attachment

    if(!$mail->Send()) {
        echo "Mailer Error: " . $mail->ErrorInfo;
    } else {
        echo "Message sent!";
3/1/2012 7:25:38 PM

Try using SMTP to send email:-

$mail->Host = "";

// optional
// used only when SMTP requires authentication  
$mail->SMTPAuth = true;
$mail->Username = 'smtp_username';
$mail->Password = 'smtp_password';
8/22/2011 10:00:53 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow