From a73dad2d4155699668ce14dc463913bb7892d3fc Mon Sep 17 00:00:00 2001 From: horus_arch Date: Sat, 21 Mar 2015 14:22:13 +0100 Subject: Skip dns validation if the MX record points to the correct server. Bugfix: Displays now flash message on success. --- server.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'server.go') diff --git a/server.go b/server.go index 746ac92..6447dc9 100644 --- a/server.go +++ b/server.go @@ -8,7 +8,8 @@ import ( ) func CreateNewEntry(email, password string) error { - serverIP := os.Getenv("FREEMAIL_SMTP_MAILER_MX") + server := os.Getenv("FREEMAIL_SMTP_MAILER_MX") + if !ValidateEmail(email) { return errors.New("This doesn't look like a mail adress.") } @@ -22,11 +23,11 @@ func CreateNewEntry(email, password string) error { vD := VirtualDomain{} vD.Name = GetDomain(vU.Email) - if !vD.ValidateDomainMX(serverIP) { - return errors.New("The MX record doesn't point to this server.") - } - if !vD.ValidateDomain(serverIP) { - return errors.New("This doesn't look like a good domain. Host not found.") + // Checks for correct DNS + if !vD.ValidateDomainMX(server) { + if !vD.ValidateDomain(server) { + return errors.New("Neither the MX record nor the domain itself point to this server. Please fix your DNS.") + } } if !vD.DomainExists() { @@ -36,6 +37,9 @@ func CreateNewEntry(email, password string) error { } vU.DomainId = vD.GetPrimaryKey() + if vU.DomainId == 0 { + return errors.New("There was an error.") + } if !vU.CreateEmail() { return errors.New("There was an error.") -- cgit v1.2.3