By using nslookup, set type=mx
You can retrieve the corresponding MX record.
The principle is to query through DNS.
Find an existing module, pydig.py, which can perform DNS queries.
It can be called in other Python modules to obtain the MX record.
In this way, a complete system for sending emails directly between an SMTP client and server is established.
After conducting some experiments, it was found that most email domains can be sent to, except for a few like 126.com and 163.com.