Skip to main content

ErisPulse Email Adapter

English | 中文


English

A powerful email adapter for the ErisPulse framework, enabling you to send and receive email messages as events within the ErisPulse ecosystem.

Features

  • Multi-Account Support: Configure multiple mailbox accounts, each with independent SMTP/IMAP settings
  • Global Configuration: Define global SMTP and IMAP settings that all accounts can inherit
  • Email Polling: Automatically checks mailbox accounts for new messages (unread emails) and converts them into standard ErisPulse events
  • DSL Sending: Send emails easily using the standard ErisPulse Send DSL
  • Attachment Support: Supports both sending and receiving email attachments
  • HTML and Plain Text: Supports both HTML and plain text email content

Installation

Install this adapter like any other ErisPulse module or adapter:

epsdk install Email

If it is installed in the same Python environment as ErisPulse, it will be discovered automatically.

Configuration

After the first run, the adapter generates a default configuration block in your config.toml file. You need to update it with your real mailbox account credentials.

Configuration Example

[EmailAdapter.global]
imap_server = "imap.example.com"  # Global IMAP server
imap_port = 993                   # IMAP port
smtp_server = "smtp.example.com"  # Global SMTP server
smtp_port = 465                   # SMTP port
ssl = true                        # Use SSL/TLS encryption
timeout = 30                      # Connection timeout (seconds)
poll_interval = 10                # Email polling interval (seconds)
max_retries = 3                   # Maximum retries for failed connections

[EmailAdapter.accounts."support@example.com"]
email = "support@example.com"     # Account email address
password = "yourpassword"         # Account password

[EmailAdapter.accounts."user@example.com"]
email = "user@example.com"
password = "anotherpassword"

Usage

Sending Email

Send emails using the standard ErisPulse Send DSL. The recipient should be the target email address.

from ErisPulse import sdk

# Send from the default account
await sdk.adapter.mail.Send.To("recipient@example.com").Text("Greetings from ErisPulse!")

# Send an email with a subject from a specific account
await sdk.adapter.mail.Send.Using("support@example.com").To("client@company.com") \
    .Subject("Important Update") \
    .Attachment("document.pdf") \
    .Text("Please review the document in the attachment.")

# Send an HTML email
html_content = """
<h1>Welcome!</h1>
<p>Thank you for using our service.</p>
"""
await sdk.adapter.mail.Send.To("user@example.com") \
    .Subject("HTML Email").Html(html_content)

Receiving Email

Received emails are automatically converted into standard message events. You can listen for them just like any other message.

from ErisPulse import sdk, adapter

@adapter.on("message")
async def handle_email_messages(data: dict):
    # Check whether the message comes from the email adapter
    if data.get("platform") == "mail":
        sender = data.get("user_id")
        subject = data["email_raw"]["subject"]
        content = data["email_raw"]["text_content"]

        print(f"New email from: {sender}")
        print(f"Subject: {subject}")
        print(f"Content:\n{content}")

        # Check attachments
        if data.get("attachments"):
            print(f"Attachments: {[a['filename'] for a in data['attachments']]}")

        # Auto-reply example
        await sdk.adapter.mail.Send.To(sender) \
            .Subject(f"Re: {subject}") \
            .Text("Your email has been received. We will reply as soon as possible.")

中文

一个为 ErisPulse 框架设计的强大邮箱适配器,支持在 ErisPulse 生态系统中以事件形式收发电子邮件。

功能特性

  • 多账户支持:可配置多个邮箱账户,每个账户可设置独立的SMTP/IMAP参数
  • 全局配置:可定义全局SMTP和IMAP设置,所有账户均可继承
  • 邮件轮询:自动检查邮箱账户中的新邮件(未读邮件),并将其转换为标准ErisPulse事件
  • DSL发送:使用标准ErisPulse Send DSL轻松发送邮件
  • 附件支持:支持发送和接收邮件附件
  • HTML与纯文本:同时支持HTML和纯文本邮件内容

安装

像安装其他ErisPulse模块或适配器一样安装本适配器:

epsdk install Email

如果与ErisPulse安装在同一个Python环境中,它将被自动发现。

配置

首次运行后,适配器会在您的config.toml文件中生成默认配置块。您需要用真实的邮箱账户信息更新它。

配置示例

[EmailAdapter.global]
imap_server = "imap.example.com"  # 全局IMAP服务器
imap_port = 993                   # IMAP端口
smtp_server = "smtp.example.com"  # 全局SMTP服务器
smtp_port = 465                   # SMTP端口
ssl = true                        # 使用SSL/TLS加密
timeout = 30                      # 连接超时时间(秒)
poll_interval = 10                # 邮件轮询间隔(秒)
max_retries = 3                   # 失败连接的最大重试次数

[EmailAdapter.accounts."support@example.com"]
email = "support@example.com"     # 账户邮箱地址
password = "yourpassword"         # 账户密码

[EmailAdapter.accounts."user@example.com"]
email = "user@example.com"
password = "anotherpassword"

使用方法

发送邮件

使用标准ErisPulse Send DSL发送邮件。接收者应为目标邮箱地址。

from ErisPulse import sdk

# 从默认账户发送
await sdk.adapter.mail.Send.To("recipient@example.com").Text("来自ErisPulse的问候!")

# 从特定账户发送带主题的邮件
await sdk.adapter.mail.Send.Using("support@example.com").To("client@company.com") \
    .Subject("重要更新"). \
    .Attachment("document.pdf").
    Text("请查看附件中的文档。") \


# 发送HTML邮件
html_content = """
<h1>欢迎!</h1>
<p>感谢使用我们的服务。</p>
"""
await sdk.adapter.mail.Send.To("user@example.com") \
    .Subject("HTML邮件").Html(html_content)

接收邮件

收到的邮件会自动转换为标准message事件。您可以像监听其他消息一样监听它们。

from ErisPulse import sdk, adapter

@adapter.on("message")
async def handle_email_messages(data: dict):
    # 检查消息是否来自邮箱适配器
    if data.get("platform") == "mail":
        sender = data.get("user_id")
        subject = data["email_raw"]["subject"]
        content = data["email_raw"]["text_content"]
        
        print(f"新邮件来自: {sender}")
        print(f"主题: {subject}")
        print(f"内容:\n{content}")
        
        # 检查附件
        if data.get("attachments"):
            print(f"附件: {[a['filename'] for a in data['attachments']]}")

        # 自动回复示例
        await sdk.adapter.mail.Send.To(sender) \
            .Subject(f"回复: {subject}") \
            .Text("已收到您的邮件,我们将尽快回复。")

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

erispulse_emailadapter-4.1.0.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

erispulse_emailadapter-4.1.0-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file erispulse_emailadapter-4.1.0.tar.gz.

File metadata

  • Download URL: erispulse_emailadapter-4.1.0.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for erispulse_emailadapter-4.1.0.tar.gz
Algorithm Hash digest
SHA256 7a597825b052d62b794a21f5f8208934fc61329f718647a61195693ee04893c6
MD5 07a1cc1563d1b06f5676cde5bbea3144
BLAKE2b-256 ddbf615a872b56b6be4e6191cbac2136f5d58b3424e878061dee79c0e4cb786b

See more details on using hashes here.

Provenance

The following attestation bundles were made for erispulse_emailadapter-4.1.0.tar.gz:

Publisher: python-publish.yml on ErisPulse/ErisPulse-EmailAdapter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file erispulse_emailadapter-4.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for erispulse_emailadapter-4.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ab8ba308e3da03db3fbf147ad3c0f31ca799bb7f3c62ecf404670c8bb1e495f
MD5 8a35a68f92c2e7da13e14379e17a514e
BLAKE2b-256 d9d8023e209ab24a35880e74535f06fd3d3163bc56301f1b8e50461373c5d83e

See more details on using hashes here.

Provenance

The following attestation bundles were made for erispulse_emailadapter-4.1.0-py3-none-any.whl:

Publisher: python-publish.yml on ErisPulse/ErisPulse-EmailAdapter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

4.1.0 This release

2 files

4.0.2

2 files

4.0.1

2 files

4.0.0

2 files

1.2.0

2 files

1.1.0

2 files

1.0.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page