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