ErisPulse-EmailAdapter 4.0.0__tar.gz → 4.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,56 +30,56 @@ class EmailGlobalConfig(AdapterConfig):
30
30
  imap_server: str = field(
31
31
  default="imap.example.com",
32
32
  metadata={
33
- "description": "默认 IMAP 服务器地址",
33
+ "description": "Default IMAP server address",
34
34
  "webui": {"widget": "text", "group": "imap", "order": 1},
35
35
  },
36
36
  )
37
37
  imap_port: int = field(
38
38
  default=993,
39
39
  metadata={
40
- "description": "默认 IMAP 端口",
40
+ "description": "Default IMAP port",
41
41
  "webui": {"widget": "number", "group": "imap", "order": 2},
42
42
  },
43
43
  )
44
44
  smtp_server: str = field(
45
45
  default="smtp.example.com",
46
46
  metadata={
47
- "description": "默认 SMTP 服务器地址",
47
+ "description": "Default SMTP server address",
48
48
  "webui": {"widget": "text", "group": "smtp", "order": 3},
49
49
  },
50
50
  )
51
51
  smtp_port: int = field(
52
52
  default=465,
53
53
  metadata={
54
- "description": "默认 SMTP 端口",
54
+ "description": "Default SMTP port",
55
55
  "webui": {"widget": "number", "group": "smtp", "order": 4},
56
56
  },
57
57
  )
58
58
  ssl: bool = field(
59
59
  default=True,
60
60
  metadata={
61
- "description": "默认是否启用 SSL",
61
+ "description": "Whether to enable SSL by default",
62
62
  "webui": {"widget": "switch", "group": "basic", "order": 5},
63
63
  },
64
64
  )
65
65
  timeout: int = field(
66
66
  default=30,
67
67
  metadata={
68
- "description": "默认连接超时时间(秒)",
68
+ "description": "Default connection timeout (seconds)",
69
69
  "webui": {"widget": "number", "group": "basic", "order": 6},
70
70
  },
71
71
  )
72
72
  poll_interval: int = field(
73
73
  default=60,
74
74
  metadata={
75
- "description": "IMAP 轮询间隔(秒)",
75
+ "description": "IMAP polling interval (seconds)",
76
76
  "webui": {"widget": "number", "group": "polling", "order": 7},
77
77
  },
78
78
  )
79
79
  max_retries: int = field(
80
80
  default=3,
81
81
  metadata={
82
- "description": "连接失败最大重试次数",
82
+ "description": "Max retries for failed connections",
83
83
  "webui": {"widget": "number", "group": "polling", "order": 8},
84
84
  },
85
85
  )
@@ -92,7 +92,7 @@ class EmailAccountConfig(BotAccountConfig):
92
92
  email: str = field(
93
93
  default="",
94
94
  metadata={
95
- "description": "邮箱地址",
95
+ "description": "Email address",
96
96
  "required": True,
97
97
  "secret": True,
98
98
  "webui": {"widget": "text", "group": "basic", "order": 1},
@@ -101,7 +101,7 @@ class EmailAccountConfig(BotAccountConfig):
101
101
  password: str = field(
102
102
  default="",
103
103
  metadata={
104
- "description": "邮箱密码/授权码",
104
+ "description": "Email password / authorization code",
105
105
  "required": True,
106
106
  "secret": True,
107
107
  "webui": {"widget": "password", "group": "basic", "order": 2},
@@ -110,42 +110,42 @@ class EmailAccountConfig(BotAccountConfig):
110
110
  imap_server: Optional[str] = field(
111
111
  default=None,
112
112
  metadata={
113
- "description": "IMAP 服务器地址(留空则使用全局默认)",
113
+ "description": "IMAP server address (leave empty to use global default)",
114
114
  "webui": {"widget": "text", "group": "imap", "order": 3},
115
115
  },
116
116
  )
117
117
  imap_port: Optional[int] = field(
118
118
  default=None,
119
119
  metadata={
120
- "description": "IMAP 端口(留空则使用全局默认)",
120
+ "description": "IMAP port (leave empty to use global default)",
121
121
  "webui": {"widget": "number", "group": "imap", "order": 4},
122
122
  },
123
123
  )
124
124
  smtp_server: Optional[str] = field(
125
125
  default=None,
126
126
  metadata={
127
- "description": "SMTP 服务器地址(留空则使用全局默认)",
127
+ "description": "SMTP server address (leave empty to use global default)",
128
128
  "webui": {"widget": "text", "group": "smtp", "order": 5},
129
129
  },
130
130
  )
131
131
  smtp_port: Optional[int] = field(
132
132
  default=None,
133
133
  metadata={
134
- "description": "SMTP 端口(留空则使用全局默认)",
134
+ "description": "SMTP port (leave empty to use global default)",
135
135
  "webui": {"widget": "number", "group": "smtp", "order": 6},
136
136
  },
137
137
  )
138
138
  ssl: bool = field(
139
139
  default=True,
140
140
  metadata={
141
- "description": "是否启用 SSL",
141
+ "description": "Enable SSL",
142
142
  "webui": {"widget": "switch", "group": "basic", "order": 7},
143
143
  },
144
144
  )
145
145
  timeout: int = field(
146
146
  default=30,
147
147
  metadata={
148
- "description": "连接超时时间(秒)",
148
+ "description": "Connection timeout (seconds)",
149
149
  "webui": {"widget": "number", "group": "basic", "order": 8},
150
150
  },
151
151
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ErisPulse-EmailAdapter
3
- Version: 4.0.0
3
+ Version: 4.0.2
4
4
  Summary: ErisPulse邮箱适配器,支持多账号管理、HTML内容和附件发送
5
5
  Author-email: wsu2059q <wsu2059@qq.com>
6
6
  License: MIT
@@ -22,7 +22,124 @@ Description-Content-Type: text/markdown
22
22
  License-File: LICENSE
23
23
  Dynamic: license-file
24
24
 
25
- # ErisPulse 邮箱适配器
25
+ # ErisPulse Email Adapter
26
+
27
+ [English](#english) | [中文](#中文)
28
+
29
+ ---
30
+
31
+ <a id="english"></a>
32
+
33
+ ## English
34
+
35
+ A powerful email adapter for the ErisPulse framework, enabling you to send and receive email messages as events within the ErisPulse ecosystem.
36
+
37
+ ### Features
38
+
39
+ - **Multi-Account Support**: Configure multiple mailbox accounts, each with independent SMTP/IMAP settings
40
+ - **Global Configuration**: Define global SMTP and IMAP settings that all accounts can inherit
41
+ - **Email Polling**: Automatically checks mailbox accounts for new messages (unread emails) and converts them into standard ErisPulse events
42
+ - **DSL Sending**: Send emails easily using the standard ErisPulse `Send` DSL
43
+ - **Attachment Support**: Supports both sending and receiving email attachments
44
+ - **HTML and Plain Text**: Supports both HTML and plain text email content
45
+
46
+ ### Installation
47
+
48
+ Install this adapter like any other ErisPulse module or adapter:
49
+
50
+ ```bash
51
+ epsdk install Email
52
+ ```
53
+
54
+ If it is installed in the same Python environment as ErisPulse, it will be discovered automatically.
55
+
56
+ ### Configuration
57
+
58
+ 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.
59
+
60
+ #### Configuration Example
61
+
62
+ ```toml
63
+ [EmailAdapter.global]
64
+ imap_server = "imap.example.com" # Global IMAP server
65
+ imap_port = 993 # IMAP port
66
+ smtp_server = "smtp.example.com" # Global SMTP server
67
+ smtp_port = 465 # SMTP port
68
+ ssl = true # Use SSL/TLS encryption
69
+ timeout = 30 # Connection timeout (seconds)
70
+ poll_interval = 10 # Email polling interval (seconds)
71
+ max_retries = 3 # Maximum retries for failed connections
72
+
73
+ [EmailAdapter.accounts."support@example.com"]
74
+ email = "support@example.com" # Account email address
75
+ password = "yourpassword" # Account password
76
+
77
+ [EmailAdapter.accounts."user@example.com"]
78
+ email = "user@example.com"
79
+ password = "anotherpassword"
80
+ ```
81
+
82
+ ### Usage
83
+
84
+ #### Sending Email
85
+
86
+ Send emails using the standard ErisPulse `Send` DSL. The recipient should be the target email address.
87
+
88
+ ```python
89
+ from ErisPulse import sdk
90
+
91
+ # Send from the default account
92
+ await sdk.adapter.mail.Send.To("recipient@example.com").Text("Greetings from ErisPulse!")
93
+
94
+ # Send an email with a subject from a specific account
95
+ await sdk.adapter.mail.Send.Using("support@example.com").To("client@company.com") \
96
+ .Subject("Important Update") \
97
+ .Attachment("document.pdf") \
98
+ .Text("Please review the document in the attachment.")
99
+
100
+ # Send an HTML email
101
+ html_content = """
102
+ <h1>Welcome!</h1>
103
+ <p>Thank you for using our service.</p>
104
+ """
105
+ await sdk.adapter.mail.Send.To("user@example.com") \
106
+ .Subject("HTML Email").Html(html_content)
107
+ ```
108
+
109
+ #### Receiving Email
110
+
111
+ Received emails are automatically converted into standard `message` events. You can listen for them just like any other message.
112
+
113
+ ```python
114
+ from ErisPulse import sdk, adapter
115
+
116
+ @adapter.on("message")
117
+ async def handle_email_messages(data: dict):
118
+ # Check whether the message comes from the email adapter
119
+ if data.get("platform") == "mail":
120
+ sender = data.get("user_id")
121
+ subject = data["email_raw"]["subject"]
122
+ content = data["email_raw"]["text_content"]
123
+
124
+ print(f"New email from: {sender}")
125
+ print(f"Subject: {subject}")
126
+ print(f"Content:\n{content}")
127
+
128
+ # Check attachments
129
+ if data.get("attachments"):
130
+ print(f"Attachments: {[a['filename'] for a in data['attachments']]}")
131
+
132
+ # Auto-reply example
133
+ await sdk.adapter.mail.Send.To(sender) \
134
+ .Subject(f"Re: {subject}") \
135
+ .Text("Your email has been received. We will reply as soon as possible.")
136
+ ```
137
+
138
+ ---
139
+
140
+ <a id="中文"></a>
141
+
142
+ ## 中文
26
143
 
27
144
  一个为 ErisPulse 框架设计的强大邮箱适配器,支持在 ErisPulse 生态系统中以事件形式收发电子邮件。
28
145
 
@@ -1,3 +1,2 @@
1
1
  [erispulse.adapter]
2
2
  email = EmailAdapter:EmailAdapter
3
- mail = EmailAdapter:EmailAdapter
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ErisPulse-EmailAdapter
3
- Version: 4.0.0
3
+ Version: 4.0.2
4
4
  Summary: ErisPulse邮箱适配器,支持多账号管理、HTML内容和附件发送
5
5
  Author-email: wsu2059q <wsu2059@qq.com>
6
6
  License: MIT
@@ -22,7 +22,124 @@ Description-Content-Type: text/markdown
22
22
  License-File: LICENSE
23
23
  Dynamic: license-file
24
24
 
25
- # ErisPulse 邮箱适配器
25
+ # ErisPulse Email Adapter
26
+
27
+ [English](#english) | [中文](#中文)
28
+
29
+ ---
30
+
31
+ <a id="english"></a>
32
+
33
+ ## English
34
+
35
+ A powerful email adapter for the ErisPulse framework, enabling you to send and receive email messages as events within the ErisPulse ecosystem.
36
+
37
+ ### Features
38
+
39
+ - **Multi-Account Support**: Configure multiple mailbox accounts, each with independent SMTP/IMAP settings
40
+ - **Global Configuration**: Define global SMTP and IMAP settings that all accounts can inherit
41
+ - **Email Polling**: Automatically checks mailbox accounts for new messages (unread emails) and converts them into standard ErisPulse events
42
+ - **DSL Sending**: Send emails easily using the standard ErisPulse `Send` DSL
43
+ - **Attachment Support**: Supports both sending and receiving email attachments
44
+ - **HTML and Plain Text**: Supports both HTML and plain text email content
45
+
46
+ ### Installation
47
+
48
+ Install this adapter like any other ErisPulse module or adapter:
49
+
50
+ ```bash
51
+ epsdk install Email
52
+ ```
53
+
54
+ If it is installed in the same Python environment as ErisPulse, it will be discovered automatically.
55
+
56
+ ### Configuration
57
+
58
+ 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.
59
+
60
+ #### Configuration Example
61
+
62
+ ```toml
63
+ [EmailAdapter.global]
64
+ imap_server = "imap.example.com" # Global IMAP server
65
+ imap_port = 993 # IMAP port
66
+ smtp_server = "smtp.example.com" # Global SMTP server
67
+ smtp_port = 465 # SMTP port
68
+ ssl = true # Use SSL/TLS encryption
69
+ timeout = 30 # Connection timeout (seconds)
70
+ poll_interval = 10 # Email polling interval (seconds)
71
+ max_retries = 3 # Maximum retries for failed connections
72
+
73
+ [EmailAdapter.accounts."support@example.com"]
74
+ email = "support@example.com" # Account email address
75
+ password = "yourpassword" # Account password
76
+
77
+ [EmailAdapter.accounts."user@example.com"]
78
+ email = "user@example.com"
79
+ password = "anotherpassword"
80
+ ```
81
+
82
+ ### Usage
83
+
84
+ #### Sending Email
85
+
86
+ Send emails using the standard ErisPulse `Send` DSL. The recipient should be the target email address.
87
+
88
+ ```python
89
+ from ErisPulse import sdk
90
+
91
+ # Send from the default account
92
+ await sdk.adapter.mail.Send.To("recipient@example.com").Text("Greetings from ErisPulse!")
93
+
94
+ # Send an email with a subject from a specific account
95
+ await sdk.adapter.mail.Send.Using("support@example.com").To("client@company.com") \
96
+ .Subject("Important Update") \
97
+ .Attachment("document.pdf") \
98
+ .Text("Please review the document in the attachment.")
99
+
100
+ # Send an HTML email
101
+ html_content = """
102
+ <h1>Welcome!</h1>
103
+ <p>Thank you for using our service.</p>
104
+ """
105
+ await sdk.adapter.mail.Send.To("user@example.com") \
106
+ .Subject("HTML Email").Html(html_content)
107
+ ```
108
+
109
+ #### Receiving Email
110
+
111
+ Received emails are automatically converted into standard `message` events. You can listen for them just like any other message.
112
+
113
+ ```python
114
+ from ErisPulse import sdk, adapter
115
+
116
+ @adapter.on("message")
117
+ async def handle_email_messages(data: dict):
118
+ # Check whether the message comes from the email adapter
119
+ if data.get("platform") == "mail":
120
+ sender = data.get("user_id")
121
+ subject = data["email_raw"]["subject"]
122
+ content = data["email_raw"]["text_content"]
123
+
124
+ print(f"New email from: {sender}")
125
+ print(f"Subject: {subject}")
126
+ print(f"Content:\n{content}")
127
+
128
+ # Check attachments
129
+ if data.get("attachments"):
130
+ print(f"Attachments: {[a['filename'] for a in data['attachments']]}")
131
+
132
+ # Auto-reply example
133
+ await sdk.adapter.mail.Send.To(sender) \
134
+ .Subject(f"Re: {subject}") \
135
+ .Text("Your email has been received. We will reply as soon as possible.")
136
+ ```
137
+
138
+ ---
139
+
140
+ <a id="中文"></a>
141
+
142
+ ## 中文
26
143
 
27
144
  一个为 ErisPulse 框架设计的强大邮箱适配器,支持在 ErisPulse 生态系统中以事件形式收发电子邮件。
28
145
 
@@ -0,0 +1,222 @@
1
+ # ErisPulse Email Adapter
2
+
3
+ [English](#english) | [中文](#中文)
4
+
5
+ ---
6
+
7
+ <a id="english"></a>
8
+
9
+ ## English
10
+
11
+ A powerful email adapter for the ErisPulse framework, enabling you to send and receive email messages as events within the ErisPulse ecosystem.
12
+
13
+ ### Features
14
+
15
+ - **Multi-Account Support**: Configure multiple mailbox accounts, each with independent SMTP/IMAP settings
16
+ - **Global Configuration**: Define global SMTP and IMAP settings that all accounts can inherit
17
+ - **Email Polling**: Automatically checks mailbox accounts for new messages (unread emails) and converts them into standard ErisPulse events
18
+ - **DSL Sending**: Send emails easily using the standard ErisPulse `Send` DSL
19
+ - **Attachment Support**: Supports both sending and receiving email attachments
20
+ - **HTML and Plain Text**: Supports both HTML and plain text email content
21
+
22
+ ### Installation
23
+
24
+ Install this adapter like any other ErisPulse module or adapter:
25
+
26
+ ```bash
27
+ epsdk install Email
28
+ ```
29
+
30
+ If it is installed in the same Python environment as ErisPulse, it will be discovered automatically.
31
+
32
+ ### Configuration
33
+
34
+ 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.
35
+
36
+ #### Configuration Example
37
+
38
+ ```toml
39
+ [EmailAdapter.global]
40
+ imap_server = "imap.example.com" # Global IMAP server
41
+ imap_port = 993 # IMAP port
42
+ smtp_server = "smtp.example.com" # Global SMTP server
43
+ smtp_port = 465 # SMTP port
44
+ ssl = true # Use SSL/TLS encryption
45
+ timeout = 30 # Connection timeout (seconds)
46
+ poll_interval = 10 # Email polling interval (seconds)
47
+ max_retries = 3 # Maximum retries for failed connections
48
+
49
+ [EmailAdapter.accounts."support@example.com"]
50
+ email = "support@example.com" # Account email address
51
+ password = "yourpassword" # Account password
52
+
53
+ [EmailAdapter.accounts."user@example.com"]
54
+ email = "user@example.com"
55
+ password = "anotherpassword"
56
+ ```
57
+
58
+ ### Usage
59
+
60
+ #### Sending Email
61
+
62
+ Send emails using the standard ErisPulse `Send` DSL. The recipient should be the target email address.
63
+
64
+ ```python
65
+ from ErisPulse import sdk
66
+
67
+ # Send from the default account
68
+ await sdk.adapter.mail.Send.To("recipient@example.com").Text("Greetings from ErisPulse!")
69
+
70
+ # Send an email with a subject from a specific account
71
+ await sdk.adapter.mail.Send.Using("support@example.com").To("client@company.com") \
72
+ .Subject("Important Update") \
73
+ .Attachment("document.pdf") \
74
+ .Text("Please review the document in the attachment.")
75
+
76
+ # Send an HTML email
77
+ html_content = """
78
+ <h1>Welcome!</h1>
79
+ <p>Thank you for using our service.</p>
80
+ """
81
+ await sdk.adapter.mail.Send.To("user@example.com") \
82
+ .Subject("HTML Email").Html(html_content)
83
+ ```
84
+
85
+ #### Receiving Email
86
+
87
+ Received emails are automatically converted into standard `message` events. You can listen for them just like any other message.
88
+
89
+ ```python
90
+ from ErisPulse import sdk, adapter
91
+
92
+ @adapter.on("message")
93
+ async def handle_email_messages(data: dict):
94
+ # Check whether the message comes from the email adapter
95
+ if data.get("platform") == "mail":
96
+ sender = data.get("user_id")
97
+ subject = data["email_raw"]["subject"]
98
+ content = data["email_raw"]["text_content"]
99
+
100
+ print(f"New email from: {sender}")
101
+ print(f"Subject: {subject}")
102
+ print(f"Content:\n{content}")
103
+
104
+ # Check attachments
105
+ if data.get("attachments"):
106
+ print(f"Attachments: {[a['filename'] for a in data['attachments']]}")
107
+
108
+ # Auto-reply example
109
+ await sdk.adapter.mail.Send.To(sender) \
110
+ .Subject(f"Re: {subject}") \
111
+ .Text("Your email has been received. We will reply as soon as possible.")
112
+ ```
113
+
114
+ ---
115
+
116
+ <a id="中文"></a>
117
+
118
+ ## 中文
119
+
120
+ 一个为 ErisPulse 框架设计的强大邮箱适配器,支持在 ErisPulse 生态系统中以事件形式收发电子邮件。
121
+
122
+ ## 功能特性
123
+
124
+ - **多账户支持**:可配置多个邮箱账户,每个账户可设置独立的SMTP/IMAP参数
125
+ - **全局配置**:可定义全局SMTP和IMAP设置,所有账户均可继承
126
+ - **邮件轮询**:自动检查邮箱账户中的新邮件(未读邮件),并将其转换为标准ErisPulse事件
127
+ - **DSL发送**:使用标准ErisPulse `Send` DSL轻松发送邮件
128
+ - **附件支持**:支持发送和接收邮件附件
129
+ - **HTML与纯文本**:同时支持HTML和纯文本邮件内容
130
+
131
+ ## 安装
132
+
133
+ 像安装其他ErisPulse模块或适配器一样安装本适配器:
134
+
135
+ ```bash
136
+ epsdk install Email
137
+ ```
138
+
139
+ 如果与ErisPulse安装在同一个Python环境中,它将被自动发现。
140
+
141
+ ## 配置
142
+
143
+ 首次运行后,适配器会在您的`config.toml`文件中生成默认配置块。您需要用真实的邮箱账户信息更新它。
144
+
145
+ ### 配置示例
146
+
147
+ ```toml
148
+ [EmailAdapter.global]
149
+ imap_server = "imap.example.com" # 全局IMAP服务器
150
+ imap_port = 993 # IMAP端口
151
+ smtp_server = "smtp.example.com" # 全局SMTP服务器
152
+ smtp_port = 465 # SMTP端口
153
+ ssl = true # 使用SSL/TLS加密
154
+ timeout = 30 # 连接超时时间(秒)
155
+ poll_interval = 10 # 邮件轮询间隔(秒)
156
+ max_retries = 3 # 失败连接的最大重试次数
157
+
158
+ [EmailAdapter.accounts."support@example.com"]
159
+ email = "support@example.com" # 账户邮箱地址
160
+ password = "yourpassword" # 账户密码
161
+
162
+ [EmailAdapter.accounts."user@example.com"]
163
+ email = "user@example.com"
164
+ password = "anotherpassword"
165
+ ```
166
+
167
+ ## 使用方法
168
+
169
+ ### 发送邮件
170
+
171
+ 使用标准ErisPulse `Send` DSL发送邮件。接收者应为目标邮箱地址。
172
+
173
+ ```python
174
+ from ErisPulse import sdk
175
+
176
+ # 从默认账户发送
177
+ await sdk.adapter.mail.Send.To("recipient@example.com").Text("来自ErisPulse的问候!")
178
+
179
+ # 从特定账户发送带主题的邮件
180
+ await sdk.adapter.mail.Send.Using("support@example.com").To("client@company.com") \
181
+ .Subject("重要更新"). \
182
+ .Attachment("document.pdf").
183
+ Text("请查看附件中的文档。") \
184
+
185
+
186
+ # 发送HTML邮件
187
+ html_content = """
188
+ <h1>欢迎!</h1>
189
+ <p>感谢使用我们的服务。</p>
190
+ """
191
+ await sdk.adapter.mail.Send.To("user@example.com") \
192
+ .Subject("HTML邮件").Html(html_content)
193
+ ```
194
+
195
+ ### 接收邮件
196
+
197
+ 收到的邮件会自动转换为标准`message`事件。您可以像监听其他消息一样监听它们。
198
+
199
+ ```python
200
+ from ErisPulse import sdk, adapter
201
+
202
+ @adapter.on("message")
203
+ async def handle_email_messages(data: dict):
204
+ # 检查消息是否来自邮箱适配器
205
+ if data.get("platform") == "mail":
206
+ sender = data.get("user_id")
207
+ subject = data["email_raw"]["subject"]
208
+ content = data["email_raw"]["text_content"]
209
+
210
+ print(f"新邮件来自: {sender}")
211
+ print(f"主题: {subject}")
212
+ print(f"内容:\n{content}")
213
+
214
+ # 检查附件
215
+ if data.get("attachments"):
216
+ print(f"附件: {[a['filename'] for a in data['attachments']]}")
217
+
218
+ # 自动回复示例
219
+ await sdk.adapter.mail.Send.To(sender) \
220
+ .Subject(f"回复: {subject}") \
221
+ .Text("已收到您的邮件,我们将尽快回复。")
222
+ ```
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ErisPulse-EmailAdapter"
3
- version = "4.0.0"
3
+ version = "4.0.2"
4
4
  description = "ErisPulse邮箱适配器,支持多账号管理、HTML内容和附件发送"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -32,4 +32,3 @@ homepage = "https://github.com/ErisPulse/ErisPulse-EmailAdapter"
32
32
 
33
33
  [project.entry-points."erispulse.adapter"]
34
34
  "email" = "EmailAdapter:EmailAdapter"
35
- "mail" = "EmailAdapter:EmailAdapter"
@@ -1,105 +0,0 @@
1
- # ErisPulse 邮箱适配器
2
-
3
- 一个为 ErisPulse 框架设计的强大邮箱适配器,支持在 ErisPulse 生态系统中以事件形式收发电子邮件。
4
-
5
- ## 功能特性
6
-
7
- - **多账户支持**:可配置多个邮箱账户,每个账户可设置独立的SMTP/IMAP参数
8
- - **全局配置**:可定义全局SMTP和IMAP设置,所有账户均可继承
9
- - **邮件轮询**:自动检查邮箱账户中的新邮件(未读邮件),并将其转换为标准ErisPulse事件
10
- - **DSL发送**:使用标准ErisPulse `Send` DSL轻松发送邮件
11
- - **附件支持**:支持发送和接收邮件附件
12
- - **HTML与纯文本**:同时支持HTML和纯文本邮件内容
13
-
14
- ## 安装
15
-
16
- 像安装其他ErisPulse模块或适配器一样安装本适配器:
17
-
18
- ```bash
19
- epsdk install Email
20
- ```
21
-
22
- 如果与ErisPulse安装在同一个Python环境中,它将被自动发现。
23
-
24
- ## 配置
25
-
26
- 首次运行后,适配器会在您的`config.toml`文件中生成默认配置块。您需要用真实的邮箱账户信息更新它。
27
-
28
- ### 配置示例
29
-
30
- ```toml
31
- [EmailAdapter.global]
32
- imap_server = "imap.example.com" # 全局IMAP服务器
33
- imap_port = 993 # IMAP端口
34
- smtp_server = "smtp.example.com" # 全局SMTP服务器
35
- smtp_port = 465 # SMTP端口
36
- ssl = true # 使用SSL/TLS加密
37
- timeout = 30 # 连接超时时间(秒)
38
- poll_interval = 10 # 邮件轮询间隔(秒)
39
- max_retries = 3 # 失败连接的最大重试次数
40
-
41
- [EmailAdapter.accounts."support@example.com"]
42
- email = "support@example.com" # 账户邮箱地址
43
- password = "yourpassword" # 账户密码
44
-
45
- [EmailAdapter.accounts."user@example.com"]
46
- email = "user@example.com"
47
- password = "anotherpassword"
48
- ```
49
-
50
- ## 使用方法
51
-
52
- ### 发送邮件
53
-
54
- 使用标准ErisPulse `Send` DSL发送邮件。接收者应为目标邮箱地址。
55
-
56
- ```python
57
- from ErisPulse import sdk
58
-
59
- # 从默认账户发送
60
- await sdk.adapter.mail.Send.To("recipient@example.com").Text("来自ErisPulse的问候!")
61
-
62
- # 从特定账户发送带主题的邮件
63
- await sdk.adapter.mail.Send.Using("support@example.com").To("client@company.com") \
64
- .Subject("重要更新"). \
65
- .Attachment("document.pdf").
66
- Text("请查看附件中的文档。") \
67
-
68
-
69
- # 发送HTML邮件
70
- html_content = """
71
- <h1>欢迎!</h1>
72
- <p>感谢使用我们的服务。</p>
73
- """
74
- await sdk.adapter.mail.Send.To("user@example.com") \
75
- .Subject("HTML邮件").Html(html_content)
76
- ```
77
-
78
- ### 接收邮件
79
-
80
- 收到的邮件会自动转换为标准`message`事件。您可以像监听其他消息一样监听它们。
81
-
82
- ```python
83
- from ErisPulse import sdk, adapter
84
-
85
- @adapter.on("message")
86
- async def handle_email_messages(data: dict):
87
- # 检查消息是否来自邮箱适配器
88
- if data.get("platform") == "mail":
89
- sender = data.get("user_id")
90
- subject = data["email_raw"]["subject"]
91
- content = data["email_raw"]["text_content"]
92
-
93
- print(f"新邮件来自: {sender}")
94
- print(f"主题: {subject}")
95
- print(f"内容:\n{content}")
96
-
97
- # 检查附件
98
- if data.get("attachments"):
99
- print(f"附件: {[a['filename'] for a in data['attachments']]}")
100
-
101
- # 自动回复示例
102
- await sdk.adapter.mail.Send.To(sender) \
103
- .Subject(f"回复: {subject}") \
104
- .Text("已收到您的邮件,我们将尽快回复。")
105
- ```