mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
chore: validate email addresses with dns
This commit is contained in:
16
utils/dns.go
Normal file
16
utils/dns.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"net"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// CheckEmailMX takes an e-mail address and verifies that an MX DNS record exists for its domain
|
||||
func CheckEmailMX(email string) bool {
|
||||
parts := strings.Split(email, "@")
|
||||
if len(parts) != 2 {
|
||||
return false
|
||||
}
|
||||
records, err := net.LookupMX(parts[1])
|
||||
return len(records) > 0 && err == nil
|
||||
}
|
Reference in New Issue
Block a user