Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Forms & Blueprints

Contact Form error mailbox given [] does not comply with RFC 2822, 3.6.2

Started by Francesco 9 years ago · 4 replies · 2351 views
9 years ago

So I need again your help guys. I'm building for the first time a contact form but despite my efforts, nothing.

The structure is the same, page "Contacts" with modular.md

<details>
<summary>modular.md</summary>


title: Contacts
cache_enable: false

form:
name: contact-form
action: /contacts
fields:

  • name: form-name
    label: Name
    placeholder: Name
    autocomplete: on
    type: text
    validate:
    required: true

  • name: form-email
    label: Email
    placeholder: Email
    type: email
    validate:
    rule: email
    required: true

  • name: form-phone
    label: Phone
    placeholder: Phone
    type: tel

  • name: textarea
    id: textarea
    label: messages
    placeholder: Tuo Messaggio
    type: textarea
    validate:
    required: true

    buttons:

  • type: submit
    value: Send

    process:

  • email:
    from: "{{ config.plugins.email.from }}"
    to:

    • "{{ config.plugins.email.from }}"
      subject: "[Contact] {{ form.value.name|e }}"
      body: "{% include 'forms/data.html.twig' %}"
  • save:
    fileprefix: contact-
    dateformat: Ymd-His-u
    extension: txt
    body: "{% include 'forms/data.txt.twig' %}"

  • display: thankyou

content:
items: '@self.modular'
order:
by: default
dir: asc
custom:

  • _map
  • _contact

</details>

Inside _contact sub-folder there is a form.md and form.html.twig has {% include 'forms/form.html.twig' %}

So the form is loaded perfectly but when I submit it, I got this error:
Address in mailbox given [] does not comply with RFC 2822, 3.6.2.

Email-Plugin is setted as SMTP with Mailtrap.io account, one personal email for "from" and "to", and I used different emails for submit test.
Everything is update.

I don't get what is going wrong, do you have any ideas?

9 years ago

Ok it seems I got the issue, on modular.md file there is

  • name: form-phone
    label: Phone
    placeholder: Phone
    type: tel

I don't know if it needs some validation pattern in order to work propely, but by deleting it the form works fine.

9 years ago

What does the whole page frontmatter look like?

9 years ago

Sorry for the late reply @rhuk!
Actually there is not much more than what I wrote above but I try to be more detailed if you need.

I have a 06.contacts folder with a modular.md and 3 subfolders: _contact , _map , thankyou

lets skip the _map subfolder, these are the frontmatters:

<details>
<summary>modular.md</summary>

title: Contacts
cache_enable: false

content:
items: '@self.modular'
order:
by: default
dir: asc
custom:

  • _map
  • _contact

    form:
    name: contact-form
    action: /contacts
    fields:

    • name: form-name
      label: Name
      placeholder: Name
      autocomplete: on
      type: text
      validate:
      required: true

    • name: form-email
      label: Email
      placeholder: Email
      type: email
      validate:
      rule: email
      required: true

    • name: form-phone
      label: Phone
      placeholder: Phone
      type: tel

    • name: textarea
      id: textarea
      label: messages
      placeholder: Tuo Messaggio
      type: textarea
      validate:
      required: true

buttons:

  • type: submit
    value: Send

process:

  • email:
    from: "{{ config.plugins.email.from }}"
    to:
    • "{{ config.plugins.email.from }}"
      subject: "[Contact] {{ form.value.name|e }}"
      body: "{% include 'forms/data.html.twig' %}"
  • save:
    fileprefix: contact-
    dateformat: Ymd-His-u
    extension: txt
    body: "{% include 'forms/data.txt.twig' %}"
  • display: thankyou

</details>

<details>
<summary>form.md in _contact subfolder</summary>

title: Form

</details>

<details>
<summary>formdata.md in thankyou subfolder</summary>

title: Thankyou !

Your email has been sent!

</details>

As I said the problem was I setted a field type in the form as "tel" , by deleting it or changing it to "text" it worked fine.

Hope this may help and thanks for your great work on Grav!

8 years ago

I'm getting this same error.
I set up a form a week or so ago with no issue. I'm revisiting it make changes to the fields. Whenever I make a change and test the form, I get this error.

<details>
<summary>YAML</summary>

YAML
---
title: New Art
access:
  site.login: true
  admin.login: true
visible: false
form:
    name: contact-form
    fields:
        - name: customer
          label: Customer
          placeholder: Enter customer name
          autofocus: on
          autocomplete: on
          type: text
          validate:
            required: true

        - name: contact
          label: Contact
          placeholder: Enter contact name
          type: text
          validate:
            required: true

        - name: phone
          label: Contact Phone Number
          placeholder: Enter contact phone number
          type: text
          validate:
            required: true

        - name: email
          label: Email
          placeholder: Enter contact email address
          type: email
          validate:
            required: true

        - name: datein
          label: Date In
          placeholder: Enter date new job is created
          type: date
          validate:
            required: true

        - name: designdue
          label: Design Due Date
          placeholder: Enter due date for design
          type: date
          validate:
            required: true

        - name: inhands
          label: In Hands
          placeholder: Enter date customer wants product in hands
          type: date
          validate:
            required: true            

        - name: product
          label: Product
          placeholder: Enter product name and number (A link to product blank is best)
          type: text
          validate:
            required: true

        - name: description
          label: Description
          placeholder: Enter any additional helpful information
          type: textarea
          validate:
            required: true

    buttons:
        - type: submit
          value: Submit
        - type: reset
          value: Reset

    process:
        - email:
            from: "{{ config.plugins.email.from }}"
            to:
              - "{{ config.plugins.email.to }}"
              - "{{ form.value.email }}"
            subject: "[Feedback] {{ form.value.name|e }}"
            body: "{% include 'forms/data.html.twig' %}"
        - save:
            fileprefix: feedback-
            dateformat: Ymd-His-u
            extension: txt
            body: "{% include 'forms/data.txt.twig' %}"
        - message: Thank you for your feedback!
        - display: thankyou
---

</details>

The form works as it is above. Small changes will throw an error though. For instance:

  • If I change validate.required to false on email, I get the error. I can change validate.required to false on the other fields with no problem.
  • If I change type to text instead of email, I get the error.
  • If I remove any of the list items under fields, I get the error.
  • I can delete all fields except for email and it works. If I change the name of the field from email to something else, it then gives that error again. Have I somehow broken something by giving the field name: email ?

It makes no sense to me why these small changes would create this error. Any insight would be appreciated!

last edited 12/22/17 by amdival

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1135 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 61 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 134 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 108 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 128 7 months ago