2

Tearing my hair out on this one.

I have an internal Win2008 server running IIS7.0 and PHP 5.2.4. The email server is on a seperate server on the same network.

I can use php's mail function to send emails with no issues but when I use PHPMailerLite, I get the message "could not instantiate mail function".

I have researched a lot and tried the following but still no joy.

  1. SetFrom - changed this to an existing email address on the mail server.
  2. Verified SMTP settings in php.ini
  3. Tested php's mail function directly and emails send no problem.
  4. Downloaded PHPMailer again in case of corruption.

Any help would be appreciated.....

Alan

Just to add, the default examples included with PHPMailer doesn't work either, same error. This code is working on other test servers for me.

$mail             = new PHPMailerLite();
$mail->IsMail(); // telling the class to use PHP Mail to send email
$mail->SetFrom("[email protected]","CareSys");
$mail->AddReplyTo("[email protected]","CareSys");
$mail->Subject    = "Weekly Planner";
$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAddress($email_add, $carer_name);
$mail->AddAttachment('../../temp/carer_planner.pdf','carer_planner.pdf');      // attachment
$mail->ConfirmReadingTo = '[email protected]';
if(!$mail->Send()) { $error_count=1; }

if ($error_count<1) { echo 'Email Sent Successfully'; }

If I put the recipient address directly in the class file on line 582 instead of the $to vairable, it works. But using $mail->AddAddress($email_add, $carer_name) will not even if I replace the $email_add variable with the receipient address.

10
  • ¿Could you paste here some of the code using PHPMailerLite? Commented Apr 19, 2011 at 17:32
  • Yes Sorry. Just to add I cannot get the default included examples to work either, same error. Commented Apr 19, 2011 at 17:40
  • 2
    There's about four lines between line 576-596 that are: $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); can you remove the @ from before the mail, run the program and report back with the new error. Commented Apr 19, 2011 at 17:43
  • Didn't know that debug option was available. The error now is a 504 error, invalid address. This error normally indicates the address in the initial HELO but I have entered this on line 152 as the value for $hostname and still the same error. Commented Apr 19, 2011 at 17:54
  • Sorry should have added that the error now is referencing line 582 in class.phpmailer-lite Commented Apr 19, 2011 at 18:06

3 Answers 3

0

That class is trying to send the message via the "sendmail" program, which is not using the php mail function. Be sure that you can execute programs from PHP via the exec/system functions, and that you can run sendmail program from PHP. The exec/system/passthru/popen functions may be disabled by your server administrator, or your php environment may be jailed and can not access the sendmail program at all.

Sign up to request clarification or add additional context in comments.

Comments

0

Try using SMTP to send email:-

$mail->IsSMTP();
$mail->Host = "smtp.example.com";    

// optional
// used only when SMTP requires authentication  
$mail->SMTPAuth = true;
$mail->Username = 'smtp_username';
$mail->Password = 'smtp_password';

Comments

0

This worked for me

$mail->SetFrom("[email protected]","CareSys", 0); //notice the third parameter

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.