summaryrefslogtreecommitdiff
path: root/server.go
diff options
context:
space:
mode:
Diffstat (limited to 'server.go')
-rw-r--r--server.go16
1 files changed, 10 insertions, 6 deletions
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.")