I'm trying to call an external PHP script from an Expression Engine form response template that sends emails using Mandrill API. The script I have works on regular PHP, I have tested it, but there is some sort of issue with the path for the includes. I've double checked the absolute paths and they are correct. Anyone see an issue?

require_once '/www/host/public_html/mandrill-api-php/Mandrill.php';
require_once '/www/host/public_html/mandrill-api-php/madrillSend.php';

$msg = "TEST MESSAGE";

$location = "{location}";
$ebrochure = "{ebrochure}"; 

$output = SendMandrill($location, $msg, $ebrochure);

echo $output;


function SendMandrill($location, $msg, $ebrochure) {

    $mandrill = new Mandrill('xxx');
    $message = array(
        'html' => null,
        'text' => $msg,
        'subject' => $subj,
        'from_email' => '[email protected]',
        'from_name' => 'Leads Account',
        'to' => array('email' => '[email protected]', 'type' => 'to),
        'headers' => array('Reply-To' => '[email protected]'),
        'important' => false,

    $async = false;
    $ip_pool = 'Main Pool';
    $send_at = '';
    $result = $mandrill->messages->send($message, $async, $ip_pool, $send_at);
    return $result;



Warning: require_once(/www/host/public_html/mandrill-api-php/madrillSend.php) [function.require-once]: failed to open stream: No such file or directory in /www/host/public_html/system/core/core.functions.php(634) : eval()'d code on line 15

Fatal error: require_once() [function.require]: Failed opening required '/www/host/public_html/mandrill-api-php/madrillSend.php' (include_path='.:/usr/share/pear:/usr/share/phpz ) in /www/host/public_html/system/core/core.functions.php(634) : eval()'d code on line 15

1 Answer 1


What have you tried? There are all these variations (assuming /www/host/public_html/ is where your EE install is and is your document root):



require_once(realpath($_SERVER["DOCUMENT_ROOT"]) . 'mandrill-api-php/Mandrill.php');

require_once($_SERVER['DOCUMENT_ROOT'] . 'mandrill-api-php/Mandrill.php');

and like 10 others. It's always possible the error is reporting the path you put in, but it actuality it's trying to load it from a relative path because EE or CI set's an environment thing. Just guessing a little, but try out some varaitions and report back.

Are file permissions all correct? Do you have two different PHP agents (one for EE core, one running everything else)?

edit Are these templates set on PHP Input or Output?? If set on Input, your $location and $ebrochure variables won't get set properly.

  • I utilized the third item and now I'm not getting an error message, but the email isn't sending. The page renders normally but doesn't show the output variable...will print_r work in a template?
    – The Hawk
    Jul 15, 2015 at 14:15
  • Yup. Go with var_dump though, it's usually more informative.
    – jrothafer
    Jul 15, 2015 at 14:17
  • Now I get this: Parse error: syntax error, unexpected ';' in /www/host/public_html/system/core/core.functions.php(634) : eval()'d code on line 14
    – The Hawk
    Jul 15, 2015 at 14:23
  • Permissions 755, PHP output...
    – The Hawk
    Jul 15, 2015 at 14:29
  • Could be curl or not PHP 5.2. Running 5.1.6, requirements say 5.2
    – The Hawk
    Jul 15, 2015 at 14:31

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.