The mailtm
library allows communication with the Mail.tm API, providing functionality for
creating disposable email accounts and managing messages. Below are detailed instructions on how to install and use the
wrapper
effectively.
Run the following command to install the mailtm
module:
go get github.com/felixstrobel/mailtm
Start by creating a Client
object. This object will act as the main entry point for interacting with the API.
import "github.com/felixstrobel/mailtm"
func main() {
client, err := mailtm.New()
if err != nil {
panic(err)
}
// Use the `client` object to perform further operations
}
When creating a MailClient
, you can customize its behavior using the WithBaseURL
and WithHTTPClient
options:
-
WithBaseURL
- Use this option to specify a custom base URL for the Mail.tm API.
client, err := mailtm.New( mailtm.WithBaseURL("https://custom.mail.api"), // Specify a custom API URL )
- Use this option to specify a custom base URL for the Mail.tm API.
-
WithHTTPClient
- Use this option to specify a custom HTTP client for the
MailClient
.client, err := mailtm.New( mailtm.WithHTTPClient(&http.Client{}), // Use a custom HTTP client )
- Use this option to specify a custom HTTP client for the
These options allow you to tailor the MailClient
for specific requirements, such as using a proxy-enabled HTTP client
or pointing to another instance of the Mail.tm API.