Agency theme: TypeError when using email form

I hope someone can help. On Agency, as per documentation I have installed Grav 1.7.26 and Form 6.0.0. I am having problems when sending emails using the Agency contact form, on send I get the Crikey message:

TypeError
Argument 1 passed to Grav\Plugin\EmailPlugin::isAssocArray() must be of the type array, null given, called in /home/donordirect/public_html/user/plugins/email/email.php on line 105

The section in my email.php is:

$this->grav->fireEvent(‘onEmailSend’, new Event([‘params’ => &$params, ‘vars’ => &$vars]));

if ($this->isAssocArray($params)) {

$this->sendFormEmail($form, $params, $vars);
} else {
foreach ($params as $email) {
$this->sendFormEmail($form, $email, $vars);

Line 105 is: if ($this->isAssocArray($params)) {

Anyone recognise the error? Thanks :slight_smile:

@les.moore,

A few questions:

  • What do you mean with:

    On Agency, as per documentation I have installed Grav 1.7.26 and Form 6.0.0.

    • What “documentation” are you referring to?
    • I hope you didn’t downgrade Grav and Form plugin…
      I noticed you are using an older version of Email plugin.
  • Is you email configuration OK? Does the same email.yaml work fine on other sites?

  • Can you debug and read the value of variable $params?

I’ve installed skeleton Agency, upgraded Grav ($ bin/gpm selfupgrade) and plugins ($ bin/gpm update).

Submitting the contact form does not throw any errors.

I do notice that version 3.2.0 of the Email plugin is different from yours. Code if ($this->isAssocArray($params)) { is on line 112.

Thanks!

I forgot to add that I can send test emails with the CLI command.

Maybe I should simply reinstall…

@les.moore,

dependencies:
    - { name: grav, version: '>=1.7.32' }
    - { name: form, version: '>=6.0.0' }

These are minimal versions requirements: Anything equal of bigger than.

Maybe I should simply reinstall…

Considering the email plugin is configured correctly, installing the latest version of Grav would be my first suggestion.

Thank you @pamtbaau . I deleted and reinstalled Grav, and uploaded the Agency template, so good so far. I updated Grav, Agency and the email plug in. Created a new mail user and successfully sent a test email. However, on sending an email via the Agency form, got exactly the same ‘missing array’ error message as the first time.

However, I now see you started by installing the Agency skeleton package. I will try again from that starting process and let you know how I get on.

@les.moore, When using the Agency skeleton, don’t forget to edit module 01.home/_contact/form.md and add:

- email:
    subject: "[Site Contact Form] {{ form.value.name|e }}"
    body: "{% include 'forms/data.html.twig' %}"

Else you’re not only getting no error, but also no email…