Emails marked as spam and some network questions.

Hi dear helpers,
I still testing this great software but I faced some problems and I have some logic questions. I’m a programmer and so I don’t have much networking experience.

The main problem that I have ist that the emails send by the Virtualmin(postfix, via smtp and also usermin) are marked as spam inside gmail and so on. I have searched a lot and found out that my problem has something to do with DKIM,SPF and reverse DNS.

I have installed DKIM and inside the DNS Settings form Virtualmin the DKIM(I tested the raw string with some online checkers and they say that it is valid) and SPF is set but still fails or better it seems that it never arrives to Google(if I check inside the mail code there is no trace from the DKIM and SPF that is see in the Virtualmin settings).
So I suppose that the DNS settings from Virtualmin are not used at all. So my question is how is the right setup? I think my Virtualmin is not acting as Nameserver, so the entries are not used. Ist that right that my Virtualmin must act as Nameserver?

My Setup is:
A-domain.com is my main domain.
Virtualmin has the domain server.A-domain.com and over server.A-domain.com:10000 i can login in Virtualmin
For the domain and subdomain i have set one A record inside my domain registrar settings(schlundtech.com) poiting to the ip adress from my server. The dedicated server is hosted by a properly hoster (hetzner.com).
I Think the error is here and i must do some entries for the nameserver im right? or im completely wrong?

I have also a question about the right smtp settings inside email clients.
I have manged to send mails(via thunderbird) but in the tutorials or forum posts that i have found the people says that the right server settings are mail.x-domain.com but with this setting it never worked for me. The only way that worked for me was using server.A-domain.com also when im sending from domain B-domain.com(B-domain@b-domain.com) for example.
Here also i think its about the dns stuff, because there i see a mx entry email.x-domain.com but this is not working.

Setup informations:
Server is running ubuntu 16.04
i have the newest gpl Virtualmin software installed, installed via the latest install.sh script
the mail log you can see at the end of the thread

Im greatfull for every hint that i can get and sorry for my horrible english.

P.s i don’t know how to attach a file, so i add my mail log here and i uploaded it to uploadfile.io(https://ufile.io/qrwg5) so if you want you can open it with a editor for better formatting (in the log there are some suspicios connects(199-127-99-217.static.avestadns.com[199.127.99.217], 113.200.102.90 and refrigerator.census.shodan.io[71.6.146.130]) somebody knows what that are? i have replaced my server IP and my domains)

p.p.s @ mods if the text is to long please remove the log data

Edit: removed the log

So people I found the solution by my self.
It was like I thought. I have done the follow things:

  • I have added the nameservers (second, third and fourth) from my domain registrar (schlundtech in my case) in the master zone (A-domain) under Webmin->Servers->BIND DNS server->select: (A-Domain)->select:Name Server

  • then I have changed the settings inside my domain registrar. Here I think there are different options for the different domain registrar in my case I could set that I would use their nameservers only as secondary and use my own as primary (in german and by schlundtech is named “Eigener Nameserver - nur sekundärer”).

  • after that I could insert server.A-domain.com as primary nameserver, I have learnt that I need a GLUE-Record because my nameserver domain (server.a-domain.com) is inside the main domain (a-domain.com) so I must add also the ip address from my server

  • I thought it was done but nope. It was not possible to do the AXFR transfer im not a network pro like i said but i found inside my logs(syslog) “Jun 4 13:28:39 server named[1365]: client 62.116.xxxx.xxxx#10212 (a-domain.com): zone transfer ‘a-domain.com/AXFR/IN’ denied” (this ip 62.116.xxxx.xxxx was also mentioned inside some FAQ from the registrar )

  • so after a bit of research i found out that i can allow transfers from specific under BIND DNS Server -> Zone Defaults !important the settings inside the zones overwrite this setting so please check inside the zone as well. **In my config per default inside the specific zone settings transfers are allowed only from 127.0.0.1 and localnets. I dont know why and i dont know if its important to allow that maybe some one can answer this. ** !!!dont forget to update/apply the config in the top right corner

  • now i could save the settings inisde the domain registrar and after some minutes my server show up as primary nameserver for that domain and now my mails from that domain pass DKIM,SPF and are not more marked as spam form gmail and so on. I think that now also mail.a-domain.com will work as smtp server but i have not tested this but i don’t see reasons that it should not work.

sorry for my basic english i hope i could help you out