diff --git a/interface/web/js/mail_domain_dkim.js b/interface/web/js/mail_domain_dkim.js
index 09a01b3d8a166eeca2977db78fa0cbb393bb5f00..fdc7ae5715a8e0195b83e066b07fd483aeaae0c6 100755
--- a/interface/web/js/mail_domain_dkim.js
+++ b/interface/web/js/mail_domain_dkim.js
@@ -31,49 +31,65 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 This Javascript is invoked by
 	* mail/templates/mail_domain_edit.htm to show and/or create the key-pair
 */
-
+var request = false;
 
 $('.subsectiontoggle').on('click', function(){
 	$(this).children().toggleClass('showing').end().next().slideToggle();
 });
 
+function setRequest(action) {
+	if (window.XMLHttpRequest) {
+		request = new XMLHttpRequest();
+	} else if (window.ActiveXObject) {
+		try {
+			request = new ActiveXObject('Msxml2.XMLHTTP');
+		}
+		catch (e) {
+			try {
+				request = new ActiveXObject('Microsoft.XMLHTTP');
+			}
+			catch (e) {}
+		}
+	}
 
-        var request = false;
+	if (!request) {
+		alert("Error creating XMLHTTP-instance");
+		return false;
+	} else {
+		// jQuery depends on domain-module active / inactive
+		var check = jQuery('#domain_module').val();
+		if ( check == "1" ) {
+			var skillsSelect = document.getElementById("domain");
+			var domain = skillsSelect.options[skillsSelect.selectedIndex].text;
+		} else { 
+			var domain = jQuery('#domain').val();
+		}
+		var selector=jQuery('#dkim_selector').val();
+		var publickey=jQuery('#dkim_public').val();
+		var privatekey=encodeURIComponent(document.getElementById("dkim_private").value)
+		request.open('POST', 'mail/mail_domain_dkim_create.php', true);
+		request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+		request.send('domain='+domain+'&action='+action+'&dkim_selector='+selector+'&dkim_public='+publickey+'&dkim_private='+privatekey);
+		request.onreadystatechange = interpretRequest;
+	}
+}
 
-        function setRequest(action,value,privatekey) {
-                if (window.XMLHttpRequest) {request = new XMLHttpRequest();}
-                else if (window.ActiveXObject) {
-                        try {request = new ActiveXObject('Msxml2.XMLHTTP');}
-                        catch (e) {
-                                try {request = new ActiveXObject('Microsoft.XMLHTTP');}
-                                catch (e) {}
-                        }
-                }
-                if (!request) {
-                        alert("Error creating XMLHTTP-instance");
-                        return false;
-                } else {
-                        request.open('POST', 'mail/mail_domain_dkim_create.php', true);
-                        request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
-                        request.send('domain='+value+'&action='+action+'&pkey='+privatekey);
-                        request.onreadystatechange = interpretRequest;
-                }
-        }
+function interpretRequest() {
+	switch (request.readyState) {
+		case 4:
+			if ( request.status != 200 ) {
+				alert("Request done but NOK\nError:"+request.status);
+			} else {
+				document.getElementsByName('dkim_selector')[0].value = request.responseXML.getElementsByTagName('selector')[0].firstChild.nodeValue;
+				document.getElementsByName('dkim_private')[0].value = request.responseXML.getElementsByTagName('privatekey')[0].firstChild.nodeValue;
+				document.getElementsByName('dkim_public')[0].value = request.responseXML.getElementsByTagName('publickey')[0].firstChild.nodeValue;
+				document.getElementsByName('dns_record')[0].value = request.responseXML.getElementsByTagName('dns_record')[0].firstChild.nodeValue;
+			}
+		break;
 
-        function interpretRequest() {
-                switch (request.readyState) {
-                        case 4:
-                                if (request.status != 200) {alert("Request done but NOK\nError:"+request.status);}
-                                else {
-                                        document.getElementsByName('dkim_private')[0].value = request.responseXML.getElementsByTagName('privatekey')[0].firstChild.nodeValue;
-                                        document.getElementsByName('dkim_public')[0].value = request.responseXML.getElementsByTagName('publickey')[0].firstChild.nodeValue;
-					document.getElementsByName('dns_record')[0].value = request.responseXML.getElementsByTagName('dns_record')[0].firstChild.nodeValue;
-                                }
-                                break;
-                        default:
-                                break;
-                }
-        }
+		default:
+		break;
+	}
+}
 
-var serverType = jQuery('#dkim_private').val();
-setRequest('show','{tmpl_var name="domain"}',serverType);
+setRequest('show');
diff --git a/interface/web/mail/mail_domain_dkim_create.php b/interface/web/mail/mail_domain_dkim_create.php
index 4769735c60c59070f2bce09cf92bc09f1252890e..bd9ff9c98b24e9c5741faadba61e4b89c53b1ec3 100644
--- a/interface/web/mail/mail_domain_dkim_create.php
+++ b/interface/web/mail/mail_domain_dkim_create.php
@@ -147,7 +147,6 @@ switch ($_POST['action']) {
 	break;
 
 	case 'show': /* show the DNS-Record onLoad */
-		$_POST=getRealPOST();
 		$private_key=$_POST['dkim_private'];
 	break;
 }
diff --git a/interface/web/mail/mail_domain_edit.php b/interface/web/mail/mail_domain_edit.php
index 6b73c7c2683b1daece341c22b3576acb832be94f..b3ea30bce6cb0c55287de20b791f883fa4ecbec2 100644
--- a/interface/web/mail/mail_domain_edit.php
+++ b/interface/web/mail/mail_domain_edit.php
@@ -176,6 +176,9 @@ class page_action extends tform_actions {
 				$domain_select .= "<option value=''></option>\r\n";
 			}
 			$app->tpl->setVar("domain_option", $domain_select);
+			$app->tpl->setVar("domain_module", 1);
+		} else {
+			$app->tpl->setVar("domain_module", 0);
 		}
 
 
diff --git a/interface/web/mail/templates/mail_domain_edit.htm b/interface/web/mail/templates/mail_domain_edit.htm
index 27dcb1c01d8f139a08b38cb30288b32f34caf35a..dbd5c6ef1e6d37957637f69c4800e13f9fc12d91 100755
--- a/interface/web/mail/templates/mail_domain_edit.htm
+++ b/interface/web/mail/templates/mail_domain_edit.htm
@@ -82,6 +82,11 @@
                     {tmpl_var name='active'}
                 </div>
             </div>
+			<tmpl_if name="domain_module">
+				<input type="hidden" name="domain_module" value="1" id="domain_module" />
+			<tmpl_else>
+				<input type="hidden" name="domain_module" value="0" id="domain_module" />
+			</tmpl_if>
             <div class="subsectiontoggle"><span></span>{tmpl_var name='dkim_settings_txt'}<em></em></div>
             <div style="display:none;">
               <div class="ctrlHolder">
@@ -97,11 +102,12 @@
               <div class="ctrlHolder">
                 <label for="dkim_private">{tmpl_var name='dkim_private_txt'}</label>
                 <textarea name="dkim_private" id="dkim_private" rows='10' cols='30'>{tmpl_var name='dkim_private'}</textarea>
-<a href="javascript:setRequest('create','{tmpl_var name='domain'}','{tmpl_var name='dkim_selector'}')">{tmpl_var name='dkim_generate_txt'}</a>
+<a href="javascript:setRequest('create')">{tmpl_var name='dkim_generate_txt'}</a>
               </div>
 		<div class="ctrlHolder">
                 <textarea name="dkim_public" style="display:none;" id="dkim_public" rows='5' cols='30' readonly>{tmpl_var name='dkim_public'}</textarea>
               </div>
+
               <div class="ctrlHolder">
                 <label for="dns_record">{tmpl_var name='dkim_dns_txt'}</label>
                 <textarea name="dns_record" id="dns_record" rows='10' cols='30' readonly>{tmpl_var name='dns_record'}</textarea>
@@ -113,7 +119,6 @@
 
         <input type="hidden" name="id" value="{tmpl_var name='id'}">
         <input type="hidden" name="type" value="local">
-
         <div class="buttonHolder buttons">
             <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onclick="submitForm('pageForm','mail/mail_domain_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
             <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onclick="loadContent('mail/mail_domain_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>