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.

Support

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

form plugins

Started by 01K 6 years ago · 5 replies · 7824 views
6 years ago

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:

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

JS
$(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

5 years ago

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 :

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

last edited 06/16/21 by pamtbaau
5 years ago

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

5 years ago

@01K:
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.

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

👍 1
5 years ago

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

👍 1
5 years ago

@anleywiver:
reply_to: ‘{{form.value.email}}

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

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 53 9 hours ago
Support · by Anna, 3 days ago
2 59 12 hours ago
Support · by Justin Young, 13 hours ago
1 30 13 hours ago
Support · by Duc , 1 week ago
2 65 5 days ago
Support · by Colin Hume, 1 week ago
2 56 5 days ago