Mailosaur lets you automate email and SMS tests as part of software development and QA.
- Unlimited test email addresses for all - every account gives users an unlimited number of test email addresses to test with.
- End-to-end (e2e) email and SMS testing Allowing you to set up end-to-end tests for password reset emails, account verification processes and MFA/one-time passcodes sent via text message.
- Fake SMTP servers Mailosaur also provides dummy SMTP servers to test with; allowing you to catch email in staging environments - preventing email being sent to customers by mistake.
You can find the full Mailosaur documentation on the website.
If you get stuck, just contact us at support@mailosaur.com.
go mod init
Then, reference mailosaur-go via import
:
import (
"github.com/mailosaur/mailosaur-go"
)
Alternatively, you can also go get
the package into your project:
go get -u github.com/mailosaur/mailosaur-go
This library is powered by the Mailosaur email & SMS testing API. You can easily check out the API itself by looking at our API reference documentation or via our Postman or Insomnia collections:
Create a free trial account for Mailosaur via the website.
Once you have this, navigate to the API tab to find the following values:
- Server ID - Servers act like projects, which group your tests together. You need this ID whenever you interact with a server via the API.
- Server Domain - Every server has its own domain name. You'll need this to send email to your server.
- API Key - You can create an API key per server (recommended), or an account-level API key to use across your whole account. Learn more about API keys.
Mailosaur gives you an unlimited number of test email addresses - with no setup or coding required!
Here's how it works:
- When you create an account, you are given a server.
- Every server has its own Server Domain name (e.g.
abc123.mailosaur.net
) - Any email address that ends with
@{YOUR_SERVER_DOMAIN}
will work with Mailosaur without any special setup. For example:build-423@abc123.mailosaur.net
john.smith@abc123.mailosaur.net
rAnDoM63423@abc123.mailosaur.net
- You can create more servers when you need them. Each one will have its own domain name.
Can't use test email addresses? You can also use SMTP to test email. By connecting your product or website to Mailosaur via SMTP, Mailosaur will catch all email your application sends, regardless of the email address.
example_test.go
package emailtests
import (
"fmt"
"testing"
"github.com/mailosaur/mailosaur-go"
)
func TestExample(t *testing.T) {
// Available in the API tab of a server
apiKey := "YOUR_API_KEY";
serverId := "SERVER_ID";
serverDomain := "SERVER_DOMAIN";
m := mailosaur.New(apiKey);
params := &mailosaur.MessageSearchParams {
Server: serverId,
}
criteria := &mailosaur.SearchCriteria {
SentTo: "anything@" + serverDomain,
}
email, err := m.Messages.Get(params, criteria)
if (err != nil) {
t.Error(err)
}
// If we have an email, print the subject
fmt.Println("Subject: " + email.Subject)
}
The test suite requires the following environment variables to be set:
export MAILOSAUR_API_KEY=your_api_key
export MAILOSAUR_SERVER=server_id
Run all tests:
go test -v
You can get us at support@mailosaur.com