Skip to main content

Overview

Email tool allows you to send emails via SMTP and read emails via IMAP. Supports Gmail, Outlook, and custom SMTP servers.

Installation

pip install "praisonai[tools]"

Environment Variables

# For Gmail
export EMAIL_ADDRESS=your@gmail.com
export EMAIL_PASSWORD=your_app_password
export EMAIL_SMTP_HOST=smtp.gmail.com
export EMAIL_SMTP_PORT=587
export EMAIL_IMAP_HOST=imap.gmail.com

Quick Start

from praisonai_tools import EmailTool

# Initialize
email = EmailTool(provider="gmail")

# Send email
email.send(
    to="[email protected]",
    subject="Hello",
    body="Hello from PraisonAI!"
)

Usage with Agent

from praisonaiagents import Agent
from praisonai_tools import EmailTool

agent = Agent(
    name="EmailAssistant",
    instructions="You help send and manage emails.",
    tools=[EmailTool(provider="gmail")]
)

response = agent.chat("Send an email to [email protected] about the meeting tomorrow")
print(response)

Available Methods

send(to, subject, body, cc=None, bcc=None)

Send an email.
from praisonai_tools import EmailTool

email = EmailTool(provider="gmail")
email.send(
    to="[email protected]",
    subject="Meeting Reminder",
    body="Don't forget our meeting at 3pm!",
    cc="[email protected]"
)

read(folder=“INBOX”, limit=10)

Read emails from a folder.
emails = email.read(folder="INBOX", limit=5)

search(query, folder=“INBOX”)

Search emails.
results = email.search("from:[email protected]", folder="INBOX")

Gmail Setup

  1. Enable 2-Factor Authentication
  2. Generate App Password at Google Account
  3. Use App Password as EMAIL_PASSWORD

Common Errors

ErrorCauseSolution
Authentication failedWrong credentialsCheck email/password
Less secure appsGmail securityUse App Password
Connection refusedWrong serverCheck SMTP/IMAP host