feat: add daily request limit and refactor access control (#759)

- Add daily request limit per IP in blacklist settings (1-1,000,000/day)
- Refactor access control logic: merge blacklist and rate limit checks
- Remove RATE_LIMIT_API_DAILY_REQUESTS env var, use database config instead
- Move x-custom-auth check earlier in middleware chain
- Add comprehensive English documentation (31 new guide pages)
- Improve code structure and error handling

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Dream Hunter
2025-11-08 12:46:30 +08:00
committed by GitHub
co-authored by Claude
parent eaeac8ebec
commit b337a44e62
44 changed files with 1983 additions and 154 deletions
@@ -0,0 +1,67 @@
# Send Email API
## Send Email via HTTP API
This is a `python` example using the `requests` library to send emails.
```python
send_body = {
"from_name": "Sender Name",
"to_name": "Recipient Name",
"to_mail": "Recipient Address",
"subject": "Email Subject",
"is_html": False, # Set whether it's HTML based on content
"content": "<Email content: html or text>",
}
res = requests.post(
"http://localhost:8787/api/send_mail",
json=send_body, headers={
"Authorization": f"Bearer {your_JWT_password}",
# "x-custom-auth": "<your_website_password>", # If custom password is enabled
"Content-Type": "application/json"
}
)
# Using body authentication
send_body = {
"token": "<your_JWT_password>",
"from_name": "Sender Name",
"to_name": "Recipient Name",
"to_mail": "Recipient Address",
"subject": "Email Subject",
"is_html": False, # Set whether it's HTML based on content
"content": "<Email content: html or text>",
}
res = requests.post(
"http://localhost:8787/external/api/send_mail",
json=send_body, headers={
"Content-Type": "application/json"
}
)
```
## Send Email via SMTP
Please first refer to [Configure SMTP Proxy](/en/guide/feature/config-smtp-proxy.html).
This is a `python` example using the `smtplib` library to send emails.
`JWT Token Password`: This is the email login password, which can be viewed in the password menu in the UI interface.
```python
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
with smtplib.SMTP('localhost', 8025) as smtp:
smtp.login("jwt", "Enter your JWT token password here")
message = MIMEMultipart()
message['From'] = "Me <me@awsl.uk>"
message['To'] = "Admin <admin@awsl.uk>"
message['Subject'] = "Test Subject"
message.attach(MIMEText("Test Content", 'html'))
smtp.sendmail("me@awsl.uk", "admin@awsl.uk", message.as_string())
```