Email Regex Go Validator

Search...

⌘K

Email Regex Go Validator

Search...

⌘K


Email Regex Go Validator

Email Regex Go Validator

The Qodex Email Regex Go Validator helps you test and validate email address patterns using Golang’s regexp package. Whether you’re writing backend validations or working on signup flows, this tool shows instant match results and group captures. Use it with our Email Generator, Username Generator, or Password Generator to simulate real-world test scenarios.

dave@qodex.ai
Possible security issues
This regex appears to be safe.
Explanation
  • [A-Z]: uppercase letters
  • [a-z]: lowercase letters
  • [0-9]: digits
  • \.: a literal dot
  • +: one or more of the preceding
  • *: zero or more of the preceding
  • ?: optional (zero or one)
  • ^: start of string
  • $: end of string
Match information
Match 1: "dave@qodex.ai" at index 0
Test your APIs today!

Write in plain English — Qodex turns it into secure, ready-to-run tests.

Regular Expression - Documentation

What is Go Email Regex?


In Go (Golang), email regex is used to check whether a given string is a valid email address. This is commonly needed for:

  • Form field validation during user registration

  • Backend API input checks

  • Sanitizing user inputs

  • Login workflows and account recovery


Go’s regexp package offers efficient, performant regex handling that makes it easy to implement these checks with accuracy and speed.


Why Validate Emails in Go?


Email validation is a critical part of any application that deals with user accounts or communication. Invalid email addresses can lead to failed notifications, security risks, and poor user experiences. Whether you’re building authentication workflows, signup forms, or profile editors, robust validation ensures only properly formatted emails enter your system.


Popular Approaches for Email Validation in Go


There are several ways to validate email addresses in Go, each with its own strengths:

  • Regular Expressions (Regex): Ideal for quickly checking if an email string matches a common pattern. Regex is highly flexible and customizable, making it the go-to for most form and API validations.

  • Built-in Packages: Go offers the package, which can parse email addresses for RFC compliance. This method is useful when you need stricter validation beyond basic pattern matching.

  • Third-party Libraries: For even more advanced validation—including DNS checks or disposable email detection—external packages can be leveraged.

Whether using regex for speed and simplicity, or built-in and external tools for in-depth checking, Go provides reliable options to suit various validation needs.


Email Validation vs. Email Verification


It's easy to mix up email validation and email verification—they sound similar, but serve distinct roles in your Go-powered workflows.

Email validation checks if an email address is formatted correctly and free of typos. For example, it ensures that "jane.doe@company.com" looks legitimate, while catching obvious issues like missing "@" symbols or double dots.

Email verification takes things further. Beyond just the format, it confirms that the email is real and owned by the user. This is typically done by sending a confirmation link or code to the address, requiring the recipient to take action. That way, you know the email not only looks right, but actually exists and belongs to someone.

Both steps help keep your user base clean and your app secure, especially during registration or password recovery flows.


Email Regex Pattern Example


A common Go-compatible regex for email validation:

^[a-zA-Z0-9._%%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$


Matches:
  • user@example.com

  • john.doe_92@company.co

  • test+1@domain.in


Doesn’t Match:
  • user@.com

  • user@domain

  • user@domain..com


Key Features & Benefits

  • Uses Go’s native regexp engine

  • Captures groups & highlights matches

  • Real-time feedback and validation

  • Ideal for login, signup, or profile forms

  • Works great with dummy emails from the Email Generator


Useful Metacharacters 

  • ^ : Start of string

  • $ : End of string

  • . : Any character except newline

  • + : One or more

  • * : Zero or more

  • ? : Optional

  • [a-zA-Z0-9._%+-] : Character set for valid email characters

  • @ : Literal “at” sign

  • \\ : Used to escape characters in Go regex


Core Go Regex Constructs Used


Anchors

  • ^ : Start of string (ensures pattern starts at beginning)

  • $ : End of string (ensures no trailing characters)


Character Classes

  • [a-zA-Z0-9._%+-] : Matches standard characters allowed before the '@'

  • [a-zA-Z0-9.-]: Matches domain name characters

  • [a-zA-Z]{2,} : Ensures the top-level domain has at least two characters


Sample Email Regex for Go


Example 1 : Basic Email Validation

package main

import (
    "fmt"
    "regexp"
)

func main() {
    pattern := regexp.MustCompile(`^[a-zA-Z0-9._%%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$`)
    email := "user@example.com"
    fmt.Println("Is valid email:", pattern.MatchString(email))
}


Try variations of this in the Go Regex Tester


Example 2 : Invalid Email Catching

emails := []string{"bademail@", "user@@domain.com", "admin@site..com"}
for _, e := range emails {
    fmt.Println("Valid:", pattern.MatchString(e))
}


Simulate test data with Email Generator


Example 3 : Case Sensitive Matching

pattern := regexp.MustCompile(`(?i)^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$`)


This enables matching mixed-case email inputs.


Custom Email Validation with go-playground/validator


Sometimes the built-in email validation just isn’t enough—you might need to enforce company domains, block certain addresses, or run extra logic. With the popular go-playground/validator, it’s easy to plug in your own rules.

Here’s how to roll out custom email validation in Go:


  1. Define your custom function
    Write a function that receives a field value and returns whether it passes your criteria. For example, you might require all emails to end with "@mycompany.com".

    import (
      "strings"
      "github.com/go-playground/validator/v10"
    )
    
    func mustCompanyDomain(fl validator.FieldLevel) bool {
        return strings.HasSuffix(fl.Field().String(), "@mycompany.com"
    
    
  2. Register it on your validator
    Associate your function with a custom tag name. This lines up with struct tags in your types.

    v := validator.New()
    v.RegisterValidation("companydomain", mustCompanyDomain
    
    
  3. Apply the tag in your structs
    Just add your custom validation tag to the struct field alongside others like required or email.

    type Signup struct {
        Email string `validate:"required,email,companydomain"`
    
    
  4. Validate and check errors
    Now, run your validation as usual! If the email doesn’t meet your function’s requirements, validation will fail.

    applicant := Signup{Email: "tester@mycompany.com"}
    err := v.Struct(applicant)
    if err != nil {
        // Handle invalid email
    
    

This approach lets your Go apps enforce any complex business logic you need, right in your struct validations. You can combine built-in rules with your own, making your signup or workflow forms both flexible and secure.


Email Validation with go-playground/validator


When working with Go, the go-playground/validator package offers a versatile way to validate email formats directly within your structs—perfect for form handling, API requests, and more. This package shines for its straightforward approach, avoiding any need for external calls like DNS or SMTP verification, which keeps things fast and dependency-free.


Core Capabilities

  • Format validation: Checks if a string meets the standard structure of an email address.

  • Struct field validation: Annotate struct fields with tags to automate checks—no manual if/else blocks required.

  • Custom validators: Create your own logic for special rules (e.g., restrict to company domains).

  • Detailed errors: Helps pinpoint exactly what failed and where.


Quickstart: Setting Up and Using go-playground/validator


  1. Install the package:

    go get
  2. Import and initialize in your code:

    import (
        "fmt"
        "github.com/go-playground/validator/v10"
    )
    
    var validate = validator.New
    
    
  3. Basic struct tag validation:

    type User struct {
        Email string `validate:"required,email"`
    }
    
    func main() {
        user := User{Email: "example@qodex.ai"}
        err := validate.Struct(user)
        if err != nil {
            // Iterate over validation errors
            for _, fieldErr := range err.(validator.ValidationErrors) {
                fmt.Printf("Field '%s' failed for tag '%s'", fieldErr.Field(), fieldErr.Tag())
            }
        } else {
            fmt.Println("Validation passed!"
    
    


Validating Individual Fields


You don’t always need a struct; you can validate a single value:

err := validate.Var("sample@qodex.ai", "required,email")
if err != nil {
    fmt.Println("Invalid email!")
} else {
    fmt.Println("Valid email!"


Creating Custom Validation Rules


For even more control, define and register custom validation functions—useful if, say, you only want to allow emails from your corporate domain.

import "strings"

func validDomain(fl validator.FieldLevel) bool {
    return strings.HasSuffix(fl.Field().String(), "@qodex.ai")
}

// Register and use your custom rule:
validate.RegisterValidation("qodexDomain", validDomain)

type User struct {
    Email string `validate:"required,email,qodexDomain"`

Whenever you want stricter requirements—perhaps only allowing emails ending with @qodex.ai—this pattern gives you flexibility while keeping validation logic cleanly organized.


Features of go-playground/validator for Email Validation


When it comes to validating emails in Go,

<mark style="
  color: #272B32;
  border-width: 1px;
  border-radius: 4px;
  box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.1),
              0px 1px 2px -1px rgba(0, 0, 0, 0.1);
  background-color: #E9D5FF;

stands out for its flexibility and simplicity—without relying on external network checks like DNS or SMTP lookups. This makes it an excellent choice for developers who want a lightweight approach to input validation.

Here’s what you get with

<mark style="
  color: #272B32;
  border-width: 1px;
  border-radius: 4px;
  box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.1),
              0px 1px 2px -1px rgba(0, 0, 0, 0.1);
  background-color: #E9D5FF;
  border-color: #C084FC;">
</mark>:
  • Format validation: Verify that an email string matches the standard email pattern, ensuring basic correctness.

  • Custom validators: Define your own validation logic for unique requirements. For instance, you can add a custom rule to enforce company-specific domains or block disposable email addresses.

  • Struct-based validation: Add validation tags directly to struct fields. For example:

    type User struct {
        Email string `validate:"required,email"`
    
    

    This makes it easy to automatically validate incoming request bodies or form data.

  • Broad data type support: Use the same package to validate not just emails, but also strings, numbers, URLs, and more.

  • Comprehensive error reporting: Receive detailed error messages, including mapping specific validation failures to their related fields—especially useful for debugging and user feedback.

With these built-in capabilities, is a robust tool for enforcing consistent and reliable email validation logic in your Go applications.


External Packages for Email Validation in Go


While Go’s built-in regexp package covers most email validation needs, several third-party libraries can further streamline or extend your validation process, especially when you need more than just syntax checks.

Here are two solid options worth considering:

go-playground/validator


If you need to validate not just emails, but a variety of struct fields in your Go application,

htmlCopyEdit<mark style="
  color: #272B32;
  border-width: 1px;
  border-radius: 4px;
  box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.1),
              0px 1px 2px -1px rgba(0, 0, 0, 0.1);
  background-color: #E9D5FF;
  border-color: #C084FC;">
  go-playground/validator
</mark>

is a versatile choice. It allows you to:

  • Validate email format on individual fields or within structs, using simple validation tags.

  • Create and register your own custom validation functions to suit your business logic.

  • Get clear, field-level error reporting for easier debugging.

This approach works well for form validation, API request checks, and anywhere you want fine-grained control over input data. Best of all, it does not require network access for DNS or SMTP checks, keeping dependencies light.


AfterShip/email-verifier

Need to take validation a step further?

htmlCopyEdit<mark style="
  color: #272B32;
  border-width: 1px;
  border-radius: 4px;
  box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.1),
              0px 1px 2px -1px rgba(0, 0, 0, 0.1);
  background-color: #E9D5FF;
  border-color: #C084FC;">
  AfterShip/email-verifier
</mark>


adds advanced checks on top of the basics:

  • Syntax validation, similar to regex-based checks.

  • DNS/MX record lookups to ensure the domain can receive mail.

  • SMTP connectivity checks to estimate if the mailbox is reachable.

  • Detection of disposable, free-provider, and role-based email addresses.

  • Catch-all domain detection.


This package is ideal for scenarios like signup forms where catching typos, dead domains, or temporary addresses is important. It provides straightforward feedback on each check, allowing you to tailor your user experience.

These packages can save you time and help boost confidence in your email validation pipeline. Choose the one that best fits your project’s requirements—lightweight and local, or robust with network checks—so your users only get the most relevant and helpful validation feedback.


Validation Rules Enforced by Go’s net/mail Package


The net/mail package in Go applies several key standards when checking email addresses:

  • The local part (before the @) cannot begin or end with a dot, and must respect a length limit of 64 characters.

  • Domains must include at least one dot, can’t start or finish with a hyphen or dot, and must not contain consecutive dots.

  • The complete address is restricted to a maximum length of 254 characters.

  • Spaces, commas, and other forbidden characters are not permitted anywhere in the email.

  • Both local and domain segments are validated for allowable characters according to RFC specifications.

These rules ensure that only emails matching widely accepted formats are considered valid, helping you avoid many common input errors in real-world forms or backend APIs.


Validating Emails Using Go’s net/mail Package


If you’re looking to step beyond regex for email validation in Go, the standard library has your back with the net/mail package. It’s purpose-built for parsing email addresses according to RFC standards and handles tricky edge cases out of the box.


Example: Basic Validation

Here’s how you can validate a list of email addresses using mail.ParseAddress:

goCopyEditpackage main

import (
    "fmt"
    "net/mail"
)

func main() {
    emails := []string{
        "test@example.com",
        "invalid-email@",
        "user@domain.co",
        "user@.com",
        "foo@bar.com",
        "missing@tld",
        "email@domain-with-hyphen.com",
    }

    for _, email := range emails {
        _, err := mail.ParseAddress(email)
        if err != nil {
            fmt.Printf("%q is invalid: %v\n", email, err)
        } else {
            fmt.Printf("%q is valid\n", email)
        }
    }
}

This method checks for:

  • Proper structure for local and domain parts

  • No leading or trailing dots in usernames

  • Domains with at least one period and no consecutive periods

  • No domains that start or end with hyphens

  • Standard character limits (e.g., 64 for local part, 254 overall)

  • Excludes forbidden characters (spaces, commas, etc.)


Validating Multiple Email Addresses


If you need to check a list of email addresses—say, a string of emails separated by commas—Go’s built-in package makes this easy. Instead of testing addresses one by one, you can use to process them all at once.


Here’s how it works:

  • Prepare a string containing email addresses, separated by commas (for example: "alice@example.com, bob@domain.org, fake-email@").

  • Use to parse the string.

  • If every address is valid, you’ll get a slice of parsed addresses to work with. If any are invalid, you’ll get an error identifying the first failure.

goCopyEditpackage main

import (
    "fmt"
    "net/mail"
)

func main() {
    emailList := "test@example.com, invalid-email@, user@domain.co, foo@bar.com"
    addresses, err := mail.ParseAddressList(emailList)
    if err != nil {
        fmt.Printf("Invalid list: %v\n", err)
        return
    }

    fmt.Println("Valid emails:")
    for _, address := range addresses {
        fmt.Println(address.Address)
    }
}

If the list contains any syntactically incorrect address (for instance, missing an '@'), the error will tell you exactly where the problem is. This approach is especially helpful when processing bulk sign-ups or admin imports where accuracy (and clear feedback) matter.


How Does Email Verification Work in Go?


While email validation helps ensure a string has the correct email format, true email verification takes things a step further: it confirms real user ownership by requiring interaction with the inbox.

1. Generate a Verification Token

After a user submits their email (for registration, password reset, etc.), your Go backend creates a unique token—often a JWT (JSON Web Token)—which encodes:

  • The user’s email

  • An expiration time

2. Send the Verification Email

The server dispatches an email containing a verification link. This link typically points to a frontend or backend endpoint and includes the token as a query parameter.

Email is usually sent using a package like gomail, with many teams relying on transactional email services such as SendGrid or Mailgun for reliable delivery.

3. User Clicks the Link

When the user clicks the verification link in their inbox, they’re sent to your verification endpoint along with the token.

Your Go server then:

  • Parses the token

  • Checks its validity and expiration

  • Extracts the embedded email

4. Activate the Account

If the token checks out, the server marks the user’s email as verified in your data store—allowing for secure logins or additional privileges.


Key Implementation Details


  • Token Expiration: For security, tokens usually expire after a short window (like 30 minutes).

  • Copy-Paste Ready: Many Go email verification flows can be quickly integrated using Go packages like jwt for token handling and gomail for SMTP integration.

  • Common Pitfalls:

    • Always provide clear error messages for expired or invalid tokens.

    • Avoid exposing sensitive user information in URLs or logs.

This process ensures the address not only looks correct but is actively controlled by the registering user. Email verification in Go is a cornerstone of ensuring that the people behind your accounts are real—and reachable.


How It Works


  1. Paste your Go-compatible email regex pattern.

  2. Enter sample test emails.

  3. Instantly see if your pattern matches and what parts are captured.

  4. Adjust and test against realistic emails using our generators.


Pro Tips for Email Regex in Go


  • Use regexp.MustCompile for predefined regex to avoid runtime errors.

  • Always test with edge cases like:

    • Missing TLD: name@domain

    • Consecutive dots: john..doe@example.com

    • Uppercase inputs: TEST@EMAIL.com

  • Regex only validates structure, not if the domain actually exists.

  • For stricter validation (e.g., no starting/ending dots), use lookahead/lookbehind where possible—though Go does not support lookbehind.


It's important to remember that regex validation is just the first step in maintaining a healthy email list. While regex helps catch formatting issues, it doesn't verify whether the email address is actually in use or if the domain is valid. To truly keep your lists clean and improve deliverability, pair regex validation with email verification—think of it as checking both the address format and confirming someone actually lives there.

Both validation and verification are only pieces of a bigger puzzle: comprehensive email testing. This industry-standard practice goes beyond regex to ensure your emails pass spam checks and that your sending domain isn’t lurking on any blacklists. By layering these approaches, you give your messages the best shot at landing exactly where you want them—right in the inbox.


Using AfterShip/email-verifier for Comprehensive Email Checks in Go


If you’re looking to take your email validation a step beyond regex, a robust Go package can handle multiple layers of checking—including DNS, MX, SMTP, disposable emails, free providers, and role-based addresses.

Here’s a quick game plan:

  • Install the package:

    go get
  • Set up and import:
    In your main.go, import the package and set up a verifier instance:

    import (
        "fmt"
        emailverifier "github.com/AfterShip/email-verifier"
    )
    
    var verifier = emailverifier.NewVerifier
    
    
  • Run a verification:
    Pass the email string to the verifier, then check the returned results for multiple criteria—structure, DNS, MX, and more:

    func main() {
        email := "test@example.com"
        ret, err := verifier.Verify(email)
        if err != nil {
            fmt.Println("Verification failed:", err)
            return
        }
        if !ret.Syntax.Valid {
            fmt.Println("Syntax invalid")
            return
        }
        fmt.Println("Email:", ret.Email)
        fmt.Println("Disposable:", ret.Disposable)
        fmt.Println("Reachable (via SMTP):", ret.Reachable)
        fmt.Println("Role Account:", ret.RoleAccount)
        fmt.Println("Free Provider:", ret.Free)
        fmt.Println("Has MX Records:", ret.HasMxRecords
    
    


Key checks performed by this tool:

  • Syntax validation: Ensures the email has a valid format.

  • DNS and MX records: Confirms the domain exists and can accept mail.

  • SMTP verification: Checks if the mailbox can actually receive messages.

  • Disposable detection: Flags addresses from temporary providers (e.g., Mailinator).

  • Free vs. Paid: Identifies common free email services (Gmail, Yahoo, etc.).

  • Role-based emails: Detects generic inboxes like info@, support@, and more.

  • Catch-all check: Determines if the domain accepts emails to any address.

You’ll also get simple results: Booleans for validity, mailbox reachability, and provider type—perfect for quick decision-making in your apps.

Heads up: You can toggle the individual features to fit your project’s needs and cut down on unnecessary network lookups.


Comparing go-playground/validator vs AfterShip/email-verifier


When it comes to picking the right email validation tool in Go, it pays to know what each library brings to the table—and where each one falls short.

go-playground/validator is all about simplicity and speed. It checks that your email string matches the correct format, making it ideal for fast, basic input validation. If you want something that’s lightweight and easy to plug into your project without extra dependencies, this fits the bill. However, keep in mind that its job stops there; it won’t confirm whether an email domain actually exists, nor will it weed out disposable addresses or run any checks against real mail servers.


On the other hand, AfterShip/email-verifier dives much deeper. Beyond verifying email format, it goes an extra mile: querying DNS and MX records to make sure the domain can receive emails, checking for disposable addresses, and even attempting SMTP-level validation. This sturdier approach means you’ll need to handle more dependencies and a bit more complexity, but the tradeoff is confidence that the email addresses you collect are actually deliverable and aren’t throwaways.


Here’s a quick way to think about it:

  • Choose go-playground/validator if you want quick format validation with minimal code overhead.

  • Go for AfterShip/email-verifier if you need comprehensive checks (domain, existence, disposables) and can accommodate a slightly more involved setup.

Both are solid choices for different job descriptions, so pick the one that’s right for your workflow.


Choosing the Right Email Validation Package for Go


Selecting an email validation package can feel like picking the right Swiss Army knife: you want the right tools for your specific adventure. Start by asking yourself a few honest questions about your application:

  • Do you just need to check that the email looks right?

  • Do you want to confirm that the domain actually exists (via DNS or MX checks)?

  • Is it important to know if the email address is a disposable or temporary one?

  • Does your app require SMTP verification for that extra layer of confidence?

Once you know what you need, look for packages that match your must-haves. For example:

  • If you’re after simple format validation, you’ll find plenty of lightweight libraries with minimal dependencies—easy to plug in and fast to use.

  • If you need deeper checks (like DNS lookups, SMTP verification, or disposable email detection), consider more comprehensive solutions. Keep in mind: these may bring in more dependencies and slightly more complex setup.

Here's a cheat sheet for comparing packages:

  • Format validation: Basic structure, e.g., name@example.com

  • DNS/MX check: Ensures the domain can receive emails.

  • SMTP verification: Attempts to connect to the mail server—most thorough, sometimes slower.

  • Disposable detection: Filters out throwaway addresses often used for short-term signups.

Before you commit, be sure to check:

  • Ease of use: Does the documentation make sense to you at 2 AM?

  • Maintenance: Is the package updated regularly? Check the release history or use tools like Snyk to gauge the project’s health.

  • Licensing: Pick packages with licenses compatible with your project.

A bit of homework upfront can save you a headache later—especially when users start entering “test@invalid...something”.


Advanced Validation with AfterShip/email-verifier


Need more than basic regex validation? AfterShip/email-verifier offers advanced layers of email address checks that go well beyond surface-level pattern matches. With this library, you can ensure higher data quality and cut down on fake or mistyped emails in your Go applications.

Here’s what sets it apart:

  • Syntax Validation: Beyond just matching a regex, it thoroughly checks the address format for RFC compliance.

  • DNS and MX Record Lookup: Verifies the domain is configured to receive emails by checking its DNS and MX records.

  • SMTP Connection Check: Attempts to connect to the mail server, so you know if the address is truly reachable.

  • Disposable Email Detection: Flags addresses from services like Mailinator that are commonly used for temporary signups.

  • Free Provider Identification: Spots emails from general providers (think Gmail, Yahoo) to help segment free users.

  • Role-based Account Detection: Identifies generic role accounts (like support@ or admin@) which are often distribution lists or unattended inboxes.

  • Catch-All Domain Detection: Tells you if a domain indiscriminately accepts all emails, which can be a red flag for deliverability.

Another bonus: Instead of cryptic errors, you get clear, actionable feedback for every failed validation step.

To get started, simply run:

Import and initialize in your project, then use its Verify method to access detailed results—everything from syntax checks to SMTP reachability and more. Tailor which features you use based on your own validation needs or preferences.


What is Email Testing (Beyond Validation & Verification)?


While validating and verifying email addresses ensures your data is clean and helps with inbox deliverability, email testing takes things one big step further. True email testing means simulating how your messages will behave in real-world scenarios—catching issues long before your recipients ever see them.

With email testing, you can:

  • Preview emails in staging and development: Safely route your test emails, so they never reach real inboxes during development.

  • Analyze HTML/CSS rendering: Instantly spot broken layouts, missing images, and tricky style bugs that may look fine in one email client but break horribly elsewhere.

  • Check against spam filters: See in advance if your emails might get flagged, and get actionable feedback to improve your chances of landing in the inbox, not the spam folder.

  • Ensure compliance and safety: Scan for risky links, blacklisted domains, and patterns that could affect your sender reputation.

In short, email testing is your safety net. It’s about ensuring that every email you send—from welcome messages to password resets—arrives looking sharp and performing exactly as intended, across environments and devices. This attention to detail is what sets reliable, professional communication apart from the crowd.


HTTP Endpoints for Email Verification in Go


Now, let’s walk through triggering email verification using HTTP endpoints in Go—a pattern that’s as reusable as your favorite helper function.

How It Works:

  1. User Registration Triggers an HTTP Request

    When a user signs up (or requests verification), your Go server exposes an endpoint like /send. The client (think: frontend or Postman) calls this with their email as a query parameter, e.g.:

  2. Generating a Token

    On receiving the request, your server creates a time-limited JWT containing the user’s email. This token acts like a temporary VIP pass—valid for, say, 30 minutes.

  3. Sending the Verification Email

    The server composes an email embedding a verification link. This link includes the JWT token in the URL. The email is dispatched using an SMTP-enabled Go package (like <mark style="color: #272B32; border-width: 1px; border-radius: 4px; box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.1), 0px 1px 2px -1px rgba(0, 0, 0, 0.1); background-color: #E9D5FF; border-color: #C084FC;">gomail</mark>), so make sure your SMTP configuration is set up and credentials are safely tucked away.

  4. User Clicks the Verification Link

    The email’s link points back to another endpoint, typically /verify, passing the token along:

    The user clicks, and your handler springs into action.

  5. Token Validation and Finalization

    The /verify handler checks the token’s validity and extracts the email. If all is well, the user receives a success message (and, ideally, their account status is updated in your database).

In Short:

  • /send?email=user@domain.com generates and emails a verification link.

  • /verify?token=... receives the user, validates the token, and completes verification.

Don't forget: since the token comes with a built-in expiration, users only have a limited window to click their magic link.


Combine With These Tools


Regex for Other Languages


Further Reading on Email Validation

  • Email validation in Python

  • Email validation in Node.js

  • Email validation in JavaScript

Common Mistakes in Email Regex


Highlight frequent issues developers face when validating emails with regex:


  • Using overly strict patterns that block valid emails with + or subdomains.

  • Forgetting to escape . in the domain.

  • Not accounting for TLDs longer than 4 characters.


Example:

Don’t use: [a-zA-Z0-9._-]+@[a-z]+\.[a-z]{2,3} — this fails for many valid domains.
Use our validator to test edge cases safely.

Frequently asked questions

Is this validator using real Golang regex?×
Yes. It mimics the behavior of Go’s built-in regexp package.
Can I use this to validate emails in a Go backend project?+
Why does my pattern miss some valid emails?+
Does this tool check if the email actually exists?+
Can I test multiple emails at once?+