{
  "schemaVersion": "1.0",
  "item": {
    "slug": "python-agentmail-send-receive",
    "name": "AgentMail sending and receiving with Python scripts",
    "source": "tencent",
    "type": "skill",
    "category": "开发工具",
    "sourceUrl": "https://clawhub.ai/lausser/python-agentmail-send-receive",
    "canonicalUrl": "https://clawhub.ai/lausser/python-agentmail-send-receive",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadMode": "redirect",
    "downloadUrl": "/downloads/python-agentmail-send-receive",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=python-agentmail-send-receive",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "installMethod": "Manual import",
    "extraction": "Extract archive",
    "prerequisites": [
      "OpenClaw"
    ],
    "packageFormat": "ZIP package",
    "includedAssets": [
      "send_email.py",
      "check_mail.py",
      "SKILL.md"
    ],
    "primaryDoc": "SKILL.md",
    "quickSetup": [
      "Download the package from Yavira.",
      "Extract the archive and review SKILL.md first.",
      "Import or place the package into your OpenClaw setup."
    ],
    "agentAssist": {
      "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
      "steps": [
        "Download the package from Yavira.",
        "Extract it into a folder your agent can access.",
        "Paste one of the prompts below and point your agent at the extracted folder."
      ],
      "prompts": [
        {
          "label": "New install",
          "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
        },
        {
          "label": "Upgrade existing",
          "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
        }
      ]
    },
    "sourceHealth": {
      "source": "tencent",
      "slug": "python-agentmail-send-receive",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-04-29T15:13:11.763Z",
      "expiresAt": "2026-05-06T15:13:11.763Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=python-agentmail-send-receive",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=python-agentmail-send-receive",
        "contentDisposition": "attachment; filename=\"python-agentmail-send-receive-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null,
        "slug": "python-agentmail-send-receive"
      },
      "scope": "item",
      "summary": "Item download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this item.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/python-agentmail-send-receive"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    },
    "downloadPageUrl": "https://openagent3.xyz/downloads/python-agentmail-send-receive",
    "agentPageUrl": "https://openagent3.xyz/skills/python-agentmail-send-receive/agent",
    "manifestUrl": "https://openagent3.xyz/skills/python-agentmail-send-receive/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/python-agentmail-send-receive/agent.md"
  },
  "agentAssist": {
    "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
    "steps": [
      "Download the package from Yavira.",
      "Extract it into a folder your agent can access.",
      "Paste one of the prompts below and point your agent at the extracted folder."
    ],
    "prompts": [
      {
        "label": "New install",
        "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
      },
      {
        "label": "Upgrade existing",
        "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
      }
    ]
  },
  "documentation": {
    "source": "clawhub",
    "primaryDoc": "SKILL.md",
    "sections": [
      {
        "title": "Skill: Email via agentmail",
        "body": "You can send and receive email as REPLACE_WITH_IDENTITY@agentmail.to using two Python scripts.\nThe scripts live in this skill folder and are deployed to ~/.openclaw/workspace/agentmail/.\nThe scripts contain placeholders which need to be replaced with real-life value:\n\nREPLACE_WITH_IDENTITY\nREPLACE_WITH_THE_HUMANS_EMAIL_ADDRESS"
      },
      {
        "title": "Deploy the skill",
        "body": "Copy the scripts and create the venv in the workspace:\n\nDEST=~/.openclaw/workspace/agentmail\nSKILL_DIR=\"$(dirname \"$(readlink -f \"$0\")\")\"    # if running from a script\n# or just point SKILL_DIR to this skill folder\n\nmkdir -p \"$DEST\"\ncp \"$SKILL_DIR/check_mail.py\" \"$SKILL_DIR/send_email.py\" \"$DEST/\"\n\ncd \"$DEST\"\n\n# Create venv (prefer uv, fall back to python)\nif command -v uv &>/dev/null; then\n  uv venv venv\n  uv pip install --python venv/bin/python agentmail python-dotenv\nelse\n  python3 -m venv venv\n  venv/bin/pip install agentmail python-dotenv\nfi"
      },
      {
        "title": "Create the .env file",
        "body": "cat > ~/.openclaw/workspace/agentmail/.env << 'EOF'\nAGENTMAIL_API_KEY=am_us_.....\nEOF\n\nThis is only necessary if you don't have the environment variable in your running environment or if you can't read it from your openclaw.json config file."
      },
      {
        "title": "Verify",
        "body": "cd ~/.openclaw/workspace/agentmail\nsource venv/bin/activate\npython check_mail.py        # should print \"No new mail.\" on a fresh inbox"
      },
      {
        "title": "Run",
        "body": "cd ~/.openclaw/workspace/agentmail\nsource venv/bin/activate\npython check_mail.py\n\nThis downloads all unread messages as JSON files into the workspace directory and marks them as read. Running it again only fetches new mail."
      },
      {
        "title": "Output files",
        "body": "Each message is saved as MAIL.<YYYYMMDDTHHmmss>.<NNN> — timestamp from the message, 3-digit sequence number within the batch.\n\nExample: MAIL.20260226T134244.001\n\nThe JSON inside contains:\n\n{\n  \"message_id\": \"<...>\",\n  \"thread_id\": \"...\",\n  \"timestamp\": \"2026-02-26 13:42:44+00:00\",\n  \"from\": \"Sender Name <sender@example.com>\",\n  \"to\": [\"REPLACE_WITH_IDENTITY@agentmail.to\"],\n  \"cc\": null,\n  \"subject\": \"Re: Hello\",\n  \"text\": \"Plain-text body...\",\n  \"html\": \"<p>HTML body...</p>\",\n  \"labels\": [\"received\", \"unread\"],\n  \"in_reply_to\": \"<original-message-id>\",\n  \"attachments\": []\n}"
      },
      {
        "title": "Reading downloaded mail",
        "body": "# List all mail files (oldest first)\nls -1 MAIL.* 2>/dev/null | sort\n\n# Read one\ncat MAIL.20260226T134244.001\n\n# Extract just the text body\npython -c \"import json,sys; print(json.load(open(sys.argv[1]))['text'])\" MAIL.20260226T134244.001"
      },
      {
        "title": "Exit codes",
        "body": "CodeMeaning0Success (mail downloaded or inbox empty)1Missing API key2API error on initial listing3Total failure (all messages errored)"
      },
      {
        "title": "Run",
        "body": "cd ~/.openclaw/workspace/agentmail\nsource venv/bin/activate\npython send_email.py\n\nsend_email.py is a template with hardcoded recipient/subject/body. For real use, modify its parameters or write a one-off script using the same pattern:\n\nimport os\nfrom dotenv import load_dotenv\nfrom agentmail import AgentMail\n\nload_dotenv()\nclient = AgentMail(api_key=os.getenv(\"AGENTMAIL_API_KEY\"))\n\nclient.inboxes.messages.send(\n    inbox_id=\"REPLACE_WITH_IDENTITY@agentmail.to\",\n    to=\"recipient@example.com\",\n    subject=\"Subject line\",\n    text=\"Plain-text body.\",\n)"
      },
      {
        "title": "send() parameters",
        "body": "ParameterRequiredDescriptioninbox_idyesAlways \"REPLACE_WITH_IDENTITY@agentmail.to\"toyesRecipient email addresssubjectnoSubject linetextnoPlain-text bodyhtmlnoHTML bodyccnoCC addressesbccnoBCC addresses"
      },
      {
        "title": "4. Replying to a Message",
        "body": "To reply in the same thread, use reply() with the message_id from a downloaded MAIL.* file:\n\nimport json, os\nfrom dotenv import load_dotenv\nfrom agentmail import AgentMail\n\nload_dotenv()\nclient = AgentMail(api_key=os.getenv(\"AGENTMAIL_API_KEY\"))\n\n# Load the message you want to reply to\nwith open(\"MAIL.20260226T134244.001\") as f:\n    msg = json.load(f)\n\nclient.inboxes.messages.reply(\n    inbox_id=\"REPLACE_WITH_IDENTITY@agentmail.to\",\n    message_id=msg[\"message_id\"],\n    text=\"This is my reply.\",\n)\n\nThis preserves threading — the reply appears in the same conversation as the original."
      },
      {
        "title": "5. Typical Workflow",
        "body": "Check mail: python check_mail.py\nRead: inspect the MAIL.* files that were created\nProcess: act on the content of each message\nReply if needed: use the reply() pattern from section 4\nClean up: rm MAIL.* when done processing\nRepeat: run check_mail.py again later for new messages"
      }
    ],
    "body": "Skill: Email via agentmail\n\nYou can send and receive email as REPLACE_WITH_IDENTITY@agentmail.to using two Python scripts. The scripts live in this skill folder and are deployed to ~/.openclaw/workspace/agentmail/. The scripts contain placeholders which need to be replaced with real-life value:\n\nREPLACE_WITH_IDENTITY\nREPLACE_WITH_THE_HUMANS_EMAIL_ADDRESS\n1. Setup\nDeploy the skill\n\nCopy the scripts and create the venv in the workspace:\n\nDEST=~/.openclaw/workspace/agentmail\nSKILL_DIR=\"$(dirname \"$(readlink -f \"$0\")\")\"    # if running from a script\n# or just point SKILL_DIR to this skill folder\n\nmkdir -p \"$DEST\"\ncp \"$SKILL_DIR/check_mail.py\" \"$SKILL_DIR/send_email.py\" \"$DEST/\"\n\ncd \"$DEST\"\n\n# Create venv (prefer uv, fall back to python)\nif command -v uv &>/dev/null; then\n  uv venv venv\n  uv pip install --python venv/bin/python agentmail python-dotenv\nelse\n  python3 -m venv venv\n  venv/bin/pip install agentmail python-dotenv\nfi\n\nCreate the .env file\ncat > ~/.openclaw/workspace/agentmail/.env << 'EOF'\nAGENTMAIL_API_KEY=am_us_.....\nEOF\n\n\nThis is only necessary if you don't have the environment variable in your running environment or if you can't read it from your openclaw.json config file.\n\nVerify\ncd ~/.openclaw/workspace/agentmail\nsource venv/bin/activate\npython check_mail.py        # should print \"No new mail.\" on a fresh inbox\n\n2. Receiving Email\nRun\ncd ~/.openclaw/workspace/agentmail\nsource venv/bin/activate\npython check_mail.py\n\n\nThis downloads all unread messages as JSON files into the workspace directory and marks them as read. Running it again only fetches new mail.\n\nOutput files\n\nEach message is saved as MAIL.<YYYYMMDDTHHmmss>.<NNN> — timestamp from the message, 3-digit sequence number within the batch.\n\nExample: MAIL.20260226T134244.001\n\nThe JSON inside contains:\n\n{\n  \"message_id\": \"<...>\",\n  \"thread_id\": \"...\",\n  \"timestamp\": \"2026-02-26 13:42:44+00:00\",\n  \"from\": \"Sender Name <sender@example.com>\",\n  \"to\": [\"REPLACE_WITH_IDENTITY@agentmail.to\"],\n  \"cc\": null,\n  \"subject\": \"Re: Hello\",\n  \"text\": \"Plain-text body...\",\n  \"html\": \"<p>HTML body...</p>\",\n  \"labels\": [\"received\", \"unread\"],\n  \"in_reply_to\": \"<original-message-id>\",\n  \"attachments\": []\n}\n\nReading downloaded mail\n# List all mail files (oldest first)\nls -1 MAIL.* 2>/dev/null | sort\n\n# Read one\ncat MAIL.20260226T134244.001\n\n# Extract just the text body\npython -c \"import json,sys; print(json.load(open(sys.argv[1]))['text'])\" MAIL.20260226T134244.001\n\nExit codes\nCode\tMeaning\n0\tSuccess (mail downloaded or inbox empty)\n1\tMissing API key\n2\tAPI error on initial listing\n3\tTotal failure (all messages errored)\n3. Sending Email\nRun\ncd ~/.openclaw/workspace/agentmail\nsource venv/bin/activate\npython send_email.py\n\n\nsend_email.py is a template with hardcoded recipient/subject/body. For real use, modify its parameters or write a one-off script using the same pattern:\n\nimport os\nfrom dotenv import load_dotenv\nfrom agentmail import AgentMail\n\nload_dotenv()\nclient = AgentMail(api_key=os.getenv(\"AGENTMAIL_API_KEY\"))\n\nclient.inboxes.messages.send(\n    inbox_id=\"REPLACE_WITH_IDENTITY@agentmail.to\",\n    to=\"recipient@example.com\",\n    subject=\"Subject line\",\n    text=\"Plain-text body.\",\n)\n\nsend() parameters\nParameter\tRequired\tDescription\ninbox_id\tyes\tAlways \"REPLACE_WITH_IDENTITY@agentmail.to\"\nto\tyes\tRecipient email address\nsubject\tno\tSubject line\ntext\tno\tPlain-text body\nhtml\tno\tHTML body\ncc\tno\tCC addresses\nbcc\tno\tBCC addresses\n4. Replying to a Message\n\nTo reply in the same thread, use reply() with the message_id from a downloaded MAIL.* file:\n\nimport json, os\nfrom dotenv import load_dotenv\nfrom agentmail import AgentMail\n\nload_dotenv()\nclient = AgentMail(api_key=os.getenv(\"AGENTMAIL_API_KEY\"))\n\n# Load the message you want to reply to\nwith open(\"MAIL.20260226T134244.001\") as f:\n    msg = json.load(f)\n\nclient.inboxes.messages.reply(\n    inbox_id=\"REPLACE_WITH_IDENTITY@agentmail.to\",\n    message_id=msg[\"message_id\"],\n    text=\"This is my reply.\",\n)\n\n\nThis preserves threading — the reply appears in the same conversation as the original.\n\n5. Typical Workflow\nCheck mail: python check_mail.py\nRead: inspect the MAIL.* files that were created\nProcess: act on the content of each message\nReply if needed: use the reply() pattern from section 4\nClean up: rm MAIL.* when done processing\nRepeat: run check_mail.py again later for new messages"
  },
  "trust": {
    "sourceLabel": "tencent",
    "provenanceUrl": "https://clawhub.ai/lausser/python-agentmail-send-receive",
    "publisherUrl": "https://clawhub.ai/lausser/python-agentmail-send-receive",
    "owner": "lausser",
    "version": "1.0.0",
    "license": null,
    "verificationStatus": "Indexed source record"
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/python-agentmail-send-receive",
    "downloadUrl": "https://openagent3.xyz/downloads/python-agentmail-send-receive",
    "agentUrl": "https://openagent3.xyz/skills/python-agentmail-send-receive/agent",
    "manifestUrl": "https://openagent3.xyz/skills/python-agentmail-send-receive/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/python-agentmail-send-receive/agent.md"
  }
}