The mailtm
module wraps the Mail.tm API and provides full functionality.
go get github.com/felixstrobel/mailtm
Firstly, create an MailClient
object. This is the object that communicates with the API.
import "github.com/felixstrobel/mailtm"
func main() {
client, err := mailtm.New()
}
After that you can directly create an account:
// With random password
client.NewAccount()
// With custom password
client.NewAccountWithPassword("password")
If you already have an account and know the address and password, you can simply sign back in:
client.RetrieveAccount("your@email.com", "your_password")
client.GetMessages(&account, 1)
client.GetMessageByID(&account, "the_id_of_the_message")
client.DeleteMessageByID(&account, "the_id_of_the_message")
client.SeenMessageByID(&account, "the_id_of_the_message")
If you decide to delete an account, you can use the DeleteAccount
function to do so:
client.DeleteAccount(&account)