Address in mailbox given [] does not comply with RFC 2822

Hi!
I’m using latest Grav 1.7 RC17 version. Developing a new project locally.
I’ve set email plugin with external SMTP server and it does send mails.

The problem is with a contact form.
I’ve made a validation and Ajax submission.
The email field is not mandatory and here comes this error:
Address in mailbox given [] does not comply with RFC 2822
If I fill the email input - no error.
I’ve seen that a few people had this problem before but those forum topics are outdated and not solved.

Here is my form:

form:
  name: kontakt-ajax-form
  template: form-messages
  refresh_prevention: true
  fields:
    -
      name: email
      label: false
      placeholder: 'e mail'
      type: email
      outerclasses: form-field
      classes: full-width
    -
      name: brand
      autofocus: 'off'
      autocomplete: 'on'
      type: select
      options:
		...
			many option
		...
      validate:
        required: true
    -
      name: telephone
      label: Phone
      placeholder: Phone
      type: tel
      validate:
        required: true
    -
      name: message
      label: false
      type: textarea
      outerclasses: form-field
      classes: full-width
      rows: null
  buttons:
    -
      type: submit
      value: Submit
      outerclasses: form-field
      classes: 'full-width btn--primary'
  process:
    -
      email:
        from: '{{ config.plugins.email.from }}'
        to: ['{{ config.plugins.email.to }}', '{{ form.value.email }}']
        subject: '[Message from] {{ form.value.name|e }}'
        body: '{% include ''forms/data.html.twig'' %}'
    -
      message: 'Thank you message'

And jQuery validation from jqueryvalidation.org:

$(function() {
	        $('#kontakt-ajax-form').validate({
				
				
				errorPlacement: function(error, element) {
					error.insertAfter( element).position({
					my:'right top',
						at:'right top',
							of:element          
						});

						error.fadeOut(3000, function() { $(this).remove(); });
				},			
				
	            rules: {
	                'data[brand]': 'required',
					'data[phone]': 'required',
	                'data[email]': {
	                    required: false,
	                    email: true
	                },
					
	            },

	            messages: {
                            xxx
	            },

	            submitHandler: function (form, event) {
					
					event.preventDefault();
					
					/*if (grecaptcha.getResponse() === '') {
						alert('Captcha error');
						return false;
					}*/

					var submitBtn = $('.button');
	                submitBtn.attr('disabled', 'disabled');
					
					var form = $('.contact__main form');
	                					


	                $.ajax({
						url: form.attr('action'),
						type: form.attr('method'),
							dataType: 'html',
							data: $(form).serialize(),						
							beforeSend: function() {

							},							
							success: function (result) {
								submitBtn.removeAttr('disabled');
								submitBtn.html('Siųsti');
								$('.message-success').show();
								$('.message-success').html(result);

							},
							  error: function(e) {

								console.log(e);
							  }
	                });										


	                return false;                
	            }
	        });

	    });

The full error from console.log:
"{\"error\":{\"type\":\"Swift_RfcComplianceException\",\"message\":\"Address in mailbox given [] does not comply with RFC 2822, 3.6.2.\",\"file\":\"C:\\\\xampp\\\\htdocs\\\\project\\\\user\\\\plugins\\\\email\\\\vendor\\\\swiftmailer\\\\swiftmailer\\\\lib\\\\classes\\\\Swift\\\\Mime\\\\Headers\\\\MailboxHeader.php\",\"line\":355}}"

Actually I don’t know is it related to form or email plugin?

It seems that it is a old bug

hi there. did you solve your issue since november 2020?

i have another one, similar to yours.
i used email plugin for forms in my website, using “from” and “to” fields in email sending and plugin configuration always worked ok.
now i just want to add a “reply_to” field field in email process, but getting this same error from MailboxHeader.php :

private function assertValidAddress($address)
{
   if (!$this->emailValidator->isValid($address, new RFCValidation())) {
      throw new Swift_RfcComplianceException(
         'Address in mailbox given ['.$address.'] does not comply with RFC 2822, 3.6.2.'
      );
   }
}

i’m typing a correct email address…
i already added a default value reply_to both in \user\config\plugins\email.yaml and in \user\plugins\email\email.yaml files.

Some could please help me?
PS if Necessary, i can open a new ticket.
Thank you

Hi!
As far as I remember I’ve just made that field as mandatory and haven’t found a proper solution

Sounds like even if not required, empty email is being validated. To me it looks like jqueryvalidation issue

1 Like

hi guys.fixed for me, too.
i have to set correct syntax
reply_to: ‘{{form.value.email}}’
for me, issue is solved. Thanks

1 Like

in form.md page, into form > process > email code, after from, to , before subject and body.