1

Having an annoying error with PHPMailer and can't figure what it's for

Mails send fine with it, but I get this:

Warning: in_array() expects parameter 2 to be array, boolean given in /dir/class.phpmailer.php on line 574

Any idea's?

CODE:

if (!in_array('PHPMailerAutoload', spl_autoload_functions())) {
  require 'PHPMailerAutoload.php';
  }

class.phpmailer.php is 2000+ lines long, obviously I can't paste it all

2
  • It says everything you need to know. in_array expects the second parameter to be an array. But a boolean is passed. Show us line 574 and affected lines. Commented Sep 14, 2013 at 11:50
  • please put your all code Commented Sep 14, 2013 at 11:52

4 Answers 4

3

It looks like your spl autoload is empty, that's why it returns a boolean, false. http://php.net/manual/en/function.spl-autoload-functions.php

Try the following:

if (!spl_autoload_functions() OR (!in_array('PHPMailerAutoload', spl_autoload_functions()))) {
  require_once('PHPMailerAutoload.php');
}
Sign up to request clarification or add additional context in comments.

1 Comment

This bug is fixed in the latest dev-master of phpmailer.
1

See documentation of spl_autoload_functions:

If the autoload stack is not activated then the return value is FALSE.

You need to check this first.

Comments

1

Folks should go a bit easy on OP... this is an error in the PHPMailer code, not in the OP's code. The accepted answer is a solution for fixing the PHOMailer IITB code. Thanks for answering it Michal-sk!

Comments

0

Your spl_autoload_functions() returns boolean not array.

It should be an array.

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.