[roller-configurator] Utilize ParseAddress function from net/mail

Bug: 42051371
Change-Id: I6c1f80fa4601ea393a6b636f86fe4739a6411c60
Reviewed-on: https://fuchsia-review.googlesource.com/c/infra/infra/+/1041975
Reviewed-by: Oliver Newman <olivernewman@google.com>
Commit-Queue: Carver Forbes <carverforbes@google.com>
diff --git a/cmd/roller-configurator/validate.go b/cmd/roller-configurator/validate.go
index 7c2779e..982c27b 100644
--- a/cmd/roller-configurator/validate.go
+++ b/cmd/roller-configurator/validate.go
@@ -8,6 +8,7 @@
 	"context"
 	"fmt"
 	"log"
+	"net/mail"
 	"path/filepath"
 	"regexp"
 	"strings"
@@ -52,6 +53,7 @@
 		fmt.Fprintf(a.GetErr(), "%s: %s\n", a.GetName(), err)
 		return 1
 	}
+	fmt.Fprintln(a.GetOut(), "Successful validation")
 	return 0
 }
 
@@ -128,9 +130,8 @@
 }
 
 func validateEmail(email string) error {
-	// Do a super-basic validity check to make sure it roughly looks like an
-	// email.
-	if strings.Count(email, "@") != 1 {
+	// Do a basic validity check to make sure it roughly looks like an email.
+	if _, err := mail.ParseAddress(email); err != nil {
 		return fmt.Errorf("invalid email %q", email)
 	}
 	return nil