We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

SOLVED - How do I fix a problem with the Email Module - InvalidArgumentException Caught

How Do I?

fanderson's avatar
fanderson
899 posts
about 4 years ago
fanderson's avatar fanderson

I just upgraded a site from 3.5.11 to 6.2.4 and have added an email contact form after installing the Email module. When I submit the form I get the following error:

It happens each time the form is submitted and there is no other error information.

Any help would be appreciated.

Thank you.

       
Andy McCormick's avatar
Andy McCormick
322 posts
about 4 years ago
Andy McCormick's avatar Andy McCormick

have you tried copying over the system/ee folder from the 6.2.4 files again to ensure that all files are copied correctly?

also, can you post your email contact form from your template? I’d like to test setting that up in 3.5.11 and then upgrade to see if I can replicate the issue.

       
fanderson's avatar
fanderson
899 posts
about 4 years ago
fanderson's avatar fanderson

Hi Andy,

Thanks for the response. This form is new with the upgrade. I was using Freeform with the 3.5.11 install. However, here is my form. I will re upload the system/ee folder to see if that helps. I’ll let you know. I look forward to your response. Note: I am using the reCapthca plugin for the captcha function.

{exp:email:contact_form 
            user_recipients="no" 
            recipients="[email protected]" 
            replyto="yes"
            redirect="5"
            return="contact/thank-you"
            form:id="contact_us"
            }
        <label for="full_name">*Name</label>

        <input type="text" name="full_name" id="full_name" value="" /><br >
        <label for="from">*Email</label>

        <input type="text" name="from" id="from" value="" /><br >
        <label for="user_message">*Message</label>

        <textarea name="user_message" id="user_message"></textarea>

        
      {captcha}
     
        
   
        <input name="submit" type='submit' class="submit-home" value="Submit" />  
       
        {/exp:email:contact_form}
       
Andy McCormick's avatar
Andy McCormick
322 posts
about 4 years ago
Andy McCormick's avatar Andy McCormick

ok. The only issue I ran into using your form is that user_message needs to be just message to work with the native contact form. ( https://docs.expressionengine.com/latest/add-ons/email.html#message-1 ). Once I update that name parameter, the form submitted without issue. This was using the native Captcha. Do you have a link to which reCaptcha add-on you are using?

thanks

       
fanderson's avatar
fanderson
899 posts
about 4 years ago
fanderson's avatar fanderson

I changed user_message to message and removed the {captcha} and still get the same error.

Here is the link: https://devot-ee.com/add-ons/recaptcha-v2

Also, to take the problem form off the home page, I moved it here to work on while I sort out the issues:

https://camclinic.com/contact/

       
Rob Allen's avatar
Rob Allen
3,105 posts
about 4 years ago
Rob Allen's avatar Rob Allen

Your Name field name needs changing as well:

<input type="text" name="name" id="full_name" value="">
       
fanderson's avatar
fanderson
899 posts
about 4 years ago
fanderson's avatar fanderson

My form now looks like this:

<label for="name">*Name</label>

        <input type="text" name="name" id="name" value="" /><br >
        <label for="from">*Email</label>

        <input type="text" name="from" id="from" value="" /><br >
        <label for="message">*Message</label>

        <textarea name="message" id="message"></textarea>

        
       {captcha} 
     
        
   
        <input name="submit" type='submit' class="submit-home" value="Submit" />

Is that correct?

       
Rob Allen's avatar
Rob Allen
3,105 posts
about 4 years ago
Rob Allen's avatar Rob Allen

Yep fields look correct now. Might be a good idea to use a proper email input type and add “required” parameters:

<label for="name">*Name</label>
<input type="text" name="name" id="name" value="" required><br >

<label for="from">*Email</label>
<input type="email" name="from" id="from" value="" required><br >

<label for="message">*Message</label>
<textarea name="message" id="message" required></textarea>
        
{captcha} 
     
<input name="submit" type='submit' class="submit-home" value="Submit" />
       
fanderson's avatar
fanderson
899 posts
about 4 years ago
fanderson's avatar fanderson

With all of the correctness I am still getting the same error. What does the error mean?

       
Rob Allen's avatar
Rob Allen
3,105 posts
about 4 years ago
Rob Allen's avatar Rob Allen

Two things to try in case the captcha addon has a bug:

  1. Remove the captcha from the form code and see what happens
  2. If you can, uninstall the captcha addon, then retest the form

EE’s contact form in EE6 does work, I use it a lot 😊

       
Rob Allen's avatar
Rob Allen
3,105 posts
about 4 years ago
Rob Allen's avatar Rob Allen

Ah I’ve just noticed you need a subject field as well, add this field to the form (you can make it a hidden field if you want)

<input type="text" name="subject" value="Contact form" required>
       
Andy McCormick's avatar
Andy McCormick
322 posts
about 4 years ago
Andy McCormick's avatar Andy McCormick

Basically, the error means that ee()->load->library('session'); isn’t being loaded somewhere it should have been loaded. Most likely an error is being thrown and not being caught, but it’s preventing the class from loading. Unfortunately, this is one of those things that could be caused by a number of things. If you want to deep dive, you can step debug this with something like XDebug and see what’s being called when the error is thrown.

Since we know the native contact form works with the native captcha, then it would seem that something 3rd party is causing this. Possibly an add-on that’s not fully compatible with EE6.

Here are some more steps to look at:

  1. I would start with ensuring that you have the latest version of all your add-ons and that all your add-ons are compatible with EE6.
  2. Disable all your add-ons and see if the error still occurs.
  3. If the error doesn’t happen with add-ons disabled, then enable add-ons individually until the error occurs again.
       
vw000's avatar
vw000
482 posts
about 4 years ago
vw000's avatar vw000

If you are using Freeform I think in Slack someone mentioned it was not yet compatible with the latest EE version and the developer is coming with an update soon.

       
fanderson's avatar
fanderson
899 posts
about 4 years ago
fanderson's avatar fanderson

Thank you to all who replied. Fortunately, we have a happy ending and I’ll share the results.

Thanks to Andy for turning off the extensions. This isolated the reCaptcha plugin as the culprit.

Thanks to Rob for helping me get the form right - third times the charm

To vw000 Freeform Express does work with EE 6.2.4, but I needed a more robust Captcha option so I opted for the email:contact_form option because integrating reCaptcha v3 is a no-brainer.

Everything is working now and I appreciate everyone’s thoughtful input.

       
vw000's avatar
vw000
482 posts
about 4 years ago
vw000's avatar vw000

I also received spam using the default EE form. I dislike reCAPTCHA with passion, and it’s also at privacy foul as it’s sending your visitors’ traffic information to Google.

You might look into hCaptcha if you need a quick replacement and even earn some cents 😊

I use the default EE captcha and I solved the spam in the most ridiculous way. I load the code from a different template in an iframe, contact page only works if JavaScript is enabled. From 3 spams per day, it’s now 0 for a year or more.

Since most bots actually only hit the form URL directly they cannot load the code as most have JS disabled and as such they are never able to post the form as no code shows.

And does that do have JS enabled, as they hit the URL POST directly they are not actually loading the iframe that has the code, which against invalids their submission. It only works if you actually load the page from the browser. It drives them crazy. ??? I killed spam completely, no complex captcha required, just the simple nice build in that comes with EE and is easy to solve.

And still works fine for those with JS disabled as they see the code on the iframe. Stupid solution, but it works. I never had a single spam on the default EE form. At least hCaptcha rewards the website, and you can donate the money to charities.

       
1 2

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.