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

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:

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

And jQuery validation from

$(function() {
				errorPlacement: function(error, element) {
					error.insertAfter( element).position({
					my:'right top',
						at:'right top',

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

	            messages: {

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

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

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

							success: function (result) {

							  error: function(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

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: ‘{{}}’
for me, issue is solved. Thanks

1 Like

This post was flagged by the community and is temporarily hidden.

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