This Go package allows you to check the availability of Microsoft email addresses (e.g., Outlook, Hotmail). It performs an HTTP request to Microsoft's API to determine if an email address is already in use.
- Check if a Microsoft email address is available.
- Supports proxy configuration.
- Comprehensive error handling and logging.
- Unit tested with >90% coverage.
To use this package, you need to have Go installed. Then, you can install the package by running:
go get github.com/ngocchien/mail_checker
import "github.com/ngocchien/mail_checker"
To create a new instance of the Microsoft Mail Checker:
checker := mail_checker.New(mail_checker.MailKindMicrosoft, mail_checker.Proxy{})
- MailKindMicrosoft: This constant represents the Microsoft mail kind.
- Proxy: (Optional) If you need to use a proxy, pass a
Proxy
struct with the necessary fields (Host, Schema, User, Password). Otherwise, pass an emptyProxy{}
.
To check the availability of an email address:
status := checker.Check("email@example.com")
fmt.Printf("Status: %d, Name: %s, Message: %s\n", status.Id, status.Name, status.Message)
- email@example.com: Replace this with the email address you want to check.
- The
Check
method returns aStatus
struct that contains:Id
: Status ID (e.g.,StatusIdLive
,StatusIdNotExists
).Name
: Status name (e.g., "Live", "Not exists").Message
: A custom message if any.Data
: Any additional data.
package main
import (
"fmt"
"github.com/ngocchien/mail_checker"
)
func main() {
proxy := mail_checker.Proxy{
Host: "127.0.0.1:8080",
}
checker := mail_checker.New(mail_checker.MailKindMicrosoft, proxy)
status := checker.Check("test@example.com")
fmt.Printf("Status: %d, Name: %s, Message: %s\n", status.Id, status.Name, status.Message)
}
If you need to use a proxy, create a Proxy
struct and pass it to the New
function:
proxy := mail_checker.Proxy{
Host: "127.0.0.1:8080",
Schema: "http",
User: "proxyUser",
Password: "proxyPassword",
}
checker := mail_checker.New(mail_checker.MailKindMicrosoft, proxy)
The package uses logrus
for logging errors. Make sure to configure logrus
according to your application's needs.
This package is thoroughly tested with more than 90% code coverage. To run the tests, use:
go test ./... -cover
Contributions are welcome! Please submit a pull request or open an issue to discuss any changes.
This project is licensed under the MIT License - see the LICENSE file for details.