← back to browse
goat command

tempmail

Token-free tempmail inbox & OTP viewer

0
views
0
likes
0
installs

Aliases: tm

raw source
const axios = require('axios');

module.exports.config = {
  name: "tempmail",
  aliases: ["tm"],
  version: "4.0",
  role: 0,
  countdown: 5,
  author: "MOHAMMAD AKASH",
  usePrefix: true,
  description: "Token-free tempmail inbox & OTP viewer",
  category: "media",
};

const API = "https://api.mail.tm";

let emailAccounts = {}; // Stores email & password internally

module.exports.onStart = async ({ api, event, args }) => {
  try {
    // --------- Inbox ---------
    if (args[0] && args[0].toLowerCase() === "inbox") {
      const email = args[1];
      if (!email) return api.sendMessage("❌ Please provide the email address", event.threadID);

      if (!emailAccounts[email]) {
        return api.sendMessage("❌ This email is not generated by the bot.", event.threadID);
      }

      const password = emailAccounts[email];
      const tokenRes = await axios.post(`${API}/token`, { address: email, password });
      const token = tokenRes.data.token;

      const inbox = await axios.get(`${API}/messages?page=1`, {
        headers: { Authorization: `Bearer ${token}` }
      });

      if (!inbox.data["hydra:member"] || inbox.data["hydra:member"].length === 0) {
        return api.sendMessage("📭 No messages yet!", event.threadID);
      }

      let out = "📬 Inbox Messages:\n\n";
      for (const msg of inbox.data["hydra:member"]) {
        out += `📩 From: ${msg.from.address}\n`;
        out += `📌 Subject: ${msg.subject || "No Subject"}\n`;
        out += `✉️ Message: ${(msg.intro || "").replace(/<[^>]+>/g, "")}\n\n`;
      }

      return api.sendMessage(out, event.threadID);
    }

    // --------- Generate new tempmail ---------
    else {
      const domainRes = await axios.get(`${API}/domains`);
      const domain = domainRes.data["hydra:member"][0].domain;

      const randomName = Math.random().toString(36).substring(2, 10);
      const email = `${randomName}@${domain}`;
      const password = randomName + "123";

      await axios.post(`${API}/accounts`, { address: email, password });

      // Store internally for inbox access without token
      emailAccounts[email] = password;

      return api.sendMessage(
        `📩 Your Temp Mail:\n\nEmail: ${email}\n\nUse this to check inbox:\n.tm inbox ${email}`,
        event.threadID
      );
    }
  } catch (err) {
    console.log(err);
    return api.sendMessage("❌ Error generating temp mail or fetching inbox.", event.threadID);
  }
};

View raw file