hmailserver-webadmin icon indicating copy to clipboard operation
hmailserver-webadmin copied to clipboard

Forwarding address field allows multiple recipients

Open RvdHout opened this issue 4 years ago • 4 comments

Forwarding email address field under account accepts: [email protected]; [email protected] (this is invalid in hMailServer)

hMailServer accepts only a single email address under forwarding thru an account, if you like to forward it to multiple recipients you are forced to use a distribution list

RvdHout avatar May 02 '21 13:05 RvdHout

That field is not required by default before saving, therefore is not checked for validity (eg. e-mail address regex). Not possible to check/validate fields which are not required.

coax avatar May 02 '21 20:05 coax

Sure you can, just be creative

// form validation
$.fn.validation = function() {

...

	if ($('#forwardaddress').length) {
		$('#forwardaddress').toggleClass( 'req', $('#forwardenabled').is(':checked') );
	}
...
}

RvdHout avatar May 02 '21 20:05 RvdHout

I understand it can be done this way (custom code for just one field) but that is not a good programming practice.

I will deal with this on a global level in the next release.

coax avatar May 03 '21 09:05 coax

Just to give you a idea, when dealt with on a global level it is even better

https://github.com/coax/hmailserver-webadmin/pull/41/commits/66d63645ae6f379763844751b3bd0f5a76a7926c

As a global solution you perhaps could give those "conditional" fields some data attribute, data-depends-on="control" and then add the 'req' class with jquery as required (similar to the above)

$.fn.hasAttr = function(name) {  
   return this.attr(name) !== undefined;
};

// form validation
$.fn.validation = function() {

...
	
	// conditional checks
	$('.form input, .form textarea').each(function() {
		if ($(this).hasAttr('data-depends-on')){ 
			var control = "#" + $(this).attr('data-depends-on');
			$(this).toggleClass( 'req', $(control).is(':checked') );
		}
	});
...
}

RvdHout avatar May 03 '21 09:05 RvdHout