3

After upgrading to Craft 4 non of my Craft Forms are working... getting the error "Symfony\Component\Mime\Address::__construct(): Argument #2 ($name) must be of type string, null given, called in /html/JANS-Staging/vendor/yiisoft/yii2-symfonymailer/src/Message.php on line 368" ... any idea please? 🙂

Also: For me the example code from here https://github.com/craftcms/contact-form/ is working on a fresh installed Craft 4 version, but not on an upgraded one from 3 to 4... not receiving any mail.

This is my form code:

<form method="post" action="" enctype="multipart/form-data" accept-charset="UTF-8" class="form" id="form-jans-contact" autocomplete="off">
      {{ csrfInput() }}
      <input id="Gr3tHousesComeToLIf3" name="Gr3tHousesComeToLIf3" type="text">
      <input type="hidden" name="toEmail" value="{{'[email protected]'|hash}}">
      <input type="hidden" name="subject" value="{{"career.application"|translate}} - {{entry.title}}">
      <input type="hidden" name="action" value="contact-form/send">
      {{ redirectInput(craft.entries.section('brochureConfirm').one.url) }}
      <div class="form-wrapper form-full">
        <div class="form-aside__left">
          <div class="form-tiles">
            <div class="form-tile">
              <div class="form-column">
                <div class="form-row f-row-5">
                  <div class="form-group">
                    <label class="form-label" for="from-firstname">{{"form.yourFirstName"|translate}}*</label>
                    <input id="from-firstname" class="form-input" type="text" name="message[{{"form.yourFirstName"|translate}}]" value="" required>
                  </div>
                </div>
                <div class="form-row f-row-5">
                  <div class="form-group">
                    <label class="form-label" for="from-lastname">{{"form.yourLastName"|translate}}*</label>
                    <input id="from-lastname" class="form-input" type="text" name="message[{{"form.yourLastName"|translate}}]" value="" required>
                  </div>
                </div>
              </div>
              <div class="form-column">
                <div class="form-row f-row-5">
                  <div class="form-group">
                    <label class="form-label" for="from-email">{{"form.emailaddress"|translate}}*</label>
                    <input id="from-email" class="form-input" type="email" name="fromEmail" value="{{ message.fromEmail ?? '' }}" required>
                  </div>
                </div>
                <div class="form-row f-row-5">
                  <div class="form-group">
                    <label class="form-label" for="from-phone">{{"form.phone"|translate}}</label>
                    <input id="from-phone" class="form-input" type="tel" name="message[Telefon]" value="">
                  </div>
                </div>
              </div>

              <div class="form-column">
                <div class="form-row f-row-5">
                  <div class="form-group">
                    <label class="form-label form-label-files" for="from-files">{{"career.uploadFiles"|translate}}:</label>
                    <input class="form-input form-files" type="file" name="attachment[]" id="from-files" multiple>
                  </div>
                </div>
              </div>
            </div>

            <div class="form-tile">
              <h4 class="form-tile__title">{{"form.yourAddress"|translate}} (Optional)</h4>
              <div class="form-column">
                <div class="form-row f-row-7">
                  <div class="form-group">
                    <label class="form-label" for="from-street">{{"form.street"|translate}}</label>
                    <input id="from-street" class="form-input" type="text" name="message[{{"form.street"|translate}}]" value="">
                  </div>
                </div>
                <div class="form-row f-row-3">
                  <div class="form-group">
                    <label class="form-label" for="from-housenumber">{{"form.number"|translate}}</label>
                    <input id="from-housenumber" class="form-input" type="text" name="message[{{"form.number"|translate}}]" value="">
                  </div>
                </div>
              </div>
              <div class="form-column">
                <div class="form-row f-row-5">
                  <div class="form-group">
                    <label class="form-label" for="from-zipcode">{{"form.zipcode"|translate}}</label>
                    <input id="from-zipcode" class="form-input" type="text" name="message[{{"form.zipcode"|translate}}]" value="">
                  </div>
                </div>
                <div class="form-row f-row-5">
                  <div class="form-group">
                    <label class="form-label" for="from-city">{{"form.city"|translate}}</label>
                    <input id="from-city" class="form-input" type="text" name="message[{{"form.city"|translate}}]" value="">
                  </div>
                </div>
              </div>

              <div class="form-column">
                <div class="form-row f-row-5">
                  <div class="form-group">
                    <label class="form-label" for="from-country">{{"form.Country"|translate}}</label>
                    <input id="from-country" class="form-input" type="text" name="message[{{"form.Country"|translate}}]" value="">
                  </div>
                </div>
                <div class="form-row f-row-5">
                  <div class="form-group">
                    <label class="form-label" for="from-comment">{{"form.comment"|translate}}</label>
                    <input id="from-comment" class="form-input" type="text" name="message[{{"form.comment"|translate}}]" value="">
                  </div>
                </div>
              </div>
            </div>

            <div class="form-tile">
              <h4 class="form-tile__title">{{"form.moreComments"|translate}}</h4>
              <div class="form-column">
                <div class="form-row f-row-10">
                  <div class="form-group">
                    <label class="form-label" for="message">{{"form.comment"|translate}}</label>
                    <textarea rows="10" cols="40" id="message" class="form-input form-textarea" name="message[body]">{{ message.message ?? '' }}</textarea>
                  </div>
                </div>
              </div>
            </div>

          </div>
        </div>
      </div>

      <div class="form-submit">
        <div class="form-end">
          <ul class="form-checkbox__list">
            <li class="form-checkbox _smaller-text">
              <input id="f-cb14" class="form-checkbox__input" name="message[{{"form.consent"|translate}}][]" type="checkbox" value="{{"form.consent.dataprivacy"|translate}}" required><label for="f-cb14">{{"form.consent.dataprivacy"|translate}}*</label>
            </li>
            <li class="form-checkbox _smaller-text">
              <input id="f-cb15" class="form-checkbox__input" name="message[{{"form.consent"|translate}}][]" type="checkbox" value="{{"form.consent.userdatas"|translate}}" required><label for="f-cb15">{{"form.consent.userdatas"|translate}}*</label>
            </li>
          </ul>
        </div>

        <button id="contact-form-submit" class="button" type="submit" form="form-jans-contact" value="Submit" title="{{ 'form.submit.title.captcha'|translate }}">
          <div class="button__decor"></div>
          <span class="button-title">{{"form.send"|translate}}</span>
          <span class="button-arrow">
            <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="35" height="20" class="button-arrow-1" viewBox="0 0 35 20"><defs><clipPath id="a"><rect width="35" height="20" transform="translate(1113 6721)" fill="#fafafa"/></clipPath></defs><g transform="translate(-1113 -6721)" clip-path="url(#a)"><g transform="translate(-1102 10350.023) rotate(-90)"><path d="M3622.151,2217.556v31" transform="translate(-2.798 -0.556)" fill="none" stroke="#0f0e0e" stroke-width="1"/><path d="M3613.023,2239l6.33,9,5.67-9" fill="none" stroke="#0f0e0e" stroke-width="1"/></g></g></svg>
          </span>
        </button>
        {{ craft.contactFormExtensions.recaptcha | raw }}
      </div>
    </form>

enter image description here

1 Answer 1

4

welcome to the CraftCMS StackExchange 👋

I dug around on the craftcms/contact-form repo and found an open issue for the same error you're describing.

Basically, (as things currently stand) you need to add a field to your form with the name fromName for it to successfully submit. With the upgrade to Craft 4 it seems that fromName joined fromEmail and message as required fields, though that wasn't documented properly.

You could either change up your "First Name" field a bit like so:

<input id="from-firstname" class="form-input" type="text" name="fromName" value="" required>

Or if you're using some JS on the frontend, you could add a hidden input field:

<input id="full-name" type="hidden" name="fromName" value="" />

...and then when your form's submit button is clicked, you could fetch the values of the yourFirstName and yourLastName field and join them and update the value of this hidden field, and then let the form submission proceed as normal. That might be a bit of a complex solution though depending on your familiarity with JS...

1
  • Thank you for your answer!! Yes, i found out the same. So with Craft 3 it was working. But in Craft 4 those fields are required for the submit :) Commented Nov 13, 2022 at 12:44

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.