/// <summary>
        /// Button "check DNS" in domain configuration have been click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btDomainCheckDNS_Click(object sender, EventArgs e)
        {
            string sFullDomain = txtDomainSelector.Text + "._domainkey." + txtDomainName.Text;

            lblDomainDNSCheckResult.Visible = false;

            try
            {
                Resolver oResolver = new Resolver();
                oResolver.Recursion = true;
                oResolver.UseCache  = false;

                // Get the name server for the domain to avoid DNS caching
                Response oResponse = oResolver.Query(sFullDomain, QType.NS, QClass.IN);
                if (oResponse.RecordsRR.GetLength(0) > 0)
                {
                    RR oNsRecord = oResponse.RecordsRR[0];
                    if (oNsRecord.RECORD.RR.RECORD.GetType() == typeof(RecordSOA))
                    {
                        RecordSOA oSoaRecord = (RecordSOA)oNsRecord.RECORD.RR.RECORD;
                        oResolver.DnsServer = oSoaRecord.MNAME;
                    }
                }

                // Get the TXT record for DKIM
                oResponse = oResolver.Query(sFullDomain, QType.TXT, QClass.IN);
                if (oResponse.RecordsTXT.GetLength(0) > 0)
                {
                    RecordTXT oTxtRecord = oResponse.RecordsTXT[0];
                    txtDomainDNS.Text = oTxtRecord.TXT.Count > 0 ? string.Join(string.Empty, oTxtRecord.TXT) : "No record found for " + sFullDomain;
                    if (oTxtRecord.TXT.Count > 0)
                    {
                        //check if public key matches suggested
                        var matchesDns       = Regex.Matches(txtDomainDNS.Text, @";\s*p=([^\s]+)");
                        var matchesSuggested = Regex.Matches(txtDNSRecord.Text, @";\s*p=([^\s]+)");
                        if (matchesDns.Count == 0 || matchesDns[0].Groups.Count <= 1)
                        {
                            lblDomainDNSCheckResult.Text      = "Could not extract public key from DNS record.";
                            lblDomainDNSCheckResult.ForeColor = Color.Firebrick;
                        }
                        else if (matchesSuggested.Count == 0 || matchesSuggested[0].Groups.Count <= 1)
                        {
                            lblDomainDNSCheckResult.Text      = "Could not extract public key from suggested DNS record.";
                            lblDomainDNSCheckResult.ForeColor = Color.Firebrick;
                        }
                        else if (String.Compare(matchesDns[0].Groups[1].ToString(), matchesSuggested[0].Groups[1].ToString(), StringComparison.Ordinal) == 0)
                        {
                            lblDomainDNSCheckResult.Text      = "DNS record public key is correct";
                            lblDomainDNSCheckResult.ForeColor = Color.Green;
                        }
                        else
                        {
                            lblDomainDNSCheckResult.Text      = "DNS record public key does not match";
                            lblDomainDNSCheckResult.ForeColor = Color.Firebrick;
                        }

                        lblDomainDNSCheckResult.Visible = true;
                    }
                }
                else
                {
                    txtDomainDNS.Text = "No record found for " + sFullDomain;
                }
            }
            catch (Exception ex)
            {
                ShowMessageBox("Error", "Coldn't get DNS record:\n" + ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtDomainDNS.Text = "Error getting record.";
            }
        }
        private RecordInfo CreateRecordInfo(RecordTXT recordTxt, string orgDomain, bool isTld, bool isInherited)
        {
            var record = string.Join(string.Empty, recordTxt.TXT);

            return(new DmarcRecordInfo(record.EscapeNonAsciiChars(), orgDomain, isTld, isInherited));
        }
        private RecordInfo CreateRecordInfo(RecordTXT recordTxt)
        {
            var record = string.Join(string.Empty, recordTxt.TXT);

            return(new SpfRecordInfo(record.EscapeNonAsciiChars()));
        }