Index: trunk/tiny-import.pl
===================================================================
--- trunk/tiny-import.pl	(revision 356)
+++ trunk/tiny-import.pl	(revision 357)
@@ -186,4 +186,6 @@
       $zone =~ s/^\&//;
       $zone =~ s/\.$//;
+      $ns =~ s/\.$//;
+      $ns = "$ns.ns.$fqdn" if $ns !~ /\./;
       $ttl = 0 if !$ttl;
       $stamp = '' if !$stamp;
@@ -206,4 +208,5 @@
 	if ($fparent) {
 	  $recsth->execute($fparent, 0, $zone, 2, $ns, 0, 0, 0, $ttl);
+	  $recsth->execute($fparent, 0, $ns, 2, $ip, 0, 0, 0, $ttl) if $ip;
 	} else {
 	  push @deferred, $rec unless $nodefer;
@@ -268,4 +271,26 @@
     } elsif ($rec =~ /^\@/) {
       $cnt{MX}++;
+
+      my ($zone,$ip,$host,$dist,$ttl,$stamp,$loc) = split /:/, $rec, 7;
+      $zone =~ s/^\.//;
+      $zone =~ s/\.$//;
+      $host =~ s/\.$//;
+      $host = "$host.mx.$zone" if $host !~ /\./;
+      $ttl = 0 if !$ttl;
+      $stamp = '' if !$stamp;
+      $loc = '' if !$loc;
+      $loc = '' if $loc =~ /^:+$/;
+
+# note we don't check for reverse domains here, because MX records don't make any sense in reverse zones.
+# if this really ever becomes an issue for someone it can be expanded to handle those weirdos
+
+      # allow for subzone MXes, since it's perfectly legitimate to simply stuff it all in a single parent zone
+      my $domid = DNSDB::_hostparent($dbh, $zone);
+      if ($domid) {
+        $recsth->execute($domid, 0, $zone, 15, $host, $dist, 0, 0, $ttl);
+	$recsth->execute($domid, 0, $host, 1, $ip, 0, 0, 0, $ttl) if $ip;
+      } else {
+	push @deferred, $rec unless $nodefer;
+      }
 
     } elsif ($rec =~ /^'/) {
