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


#1

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

modular.md

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

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?


#2

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.


#3

What does the whole page frontmatter look like?


#4

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:

modular.md

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

form.md in _contact subfolder

title: Form

formdata.md in thankyou subfolder

title: Thankyou !

Your email has been sent!

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!


#5

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.

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
---

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!