A JavaScript wrapper around the mail.tm api.
Probably one of the best API for creating temporary email accounts.
npm install @cemalgnlts/mailjs
https://cdn.jsdelivr.net/gh/cemalgnlts/Mailjs@latest/Mailjs.min.js
Returns a Promise object after the function is called. If the request is sent correctly, status
returns true. If it returns incorrect, the status
will be false and the message
in the data is also added.
A successfull response example:
{
"status": true,
"message": "ok",
"data": ...
}
A failed response example:
{
"status": false,
"message": "Invalid credentials.",
"data": ...
}
To see all results, check out the API page: https://api.mail.tm/
User needs to login to access JWT token. Registration does not return this information, log in after registration.
After the login process, the user's JWT token and ID are assigned to mailjs.token
and mailjs.id
mailjs.getDomains()
.then(console.log)
mailjs.getDomain("[domain id]")
.then(console.log)
mailjs.register("user@example.com", "password")
.then(console.log)
mailjs.token
and mailjs.id
can be used to access the user token and id later.
mailjs.login("user@example.com", "password")
.then(console.log)
mailjs.me()
.then(console.log)
mailjs.deleteMe()
.then(console.log)
You can also use the id to access the user's information and delete their account.
mailjs.deleteAccount("[account id]")
.then(console.log)
mailjs.getAccount("[account id]")
.then(console.log)
mailjs.getMessages()
.then(console.log)
mailjs.getMessage("[message id]")
.then(console.log)
mailjs.deleteMessage("[message id]")
.then(console.log)
true
for make readed. false
for make unreaded.
mailjs.setMessageSeen("[message id]", true)
.then(console.log)
mailjs.getSource("[message id]")
.then(console.log)
Creates and logs in an account with a random username and password.
mailjs.createOneAccount()
.then(console.log);
{
"status": true,
"data": {
"username": "user@example.com",
"password": "my-password"
}
}