Оглавление
Этот скрипт отправляет электронные письма через SMTP прямо из Python-скрипта SeaTable. Вы можете использовать его для уведомлений, отчётов или любой автоматической рассылки на основе данных SeaTable. Скрипт поддерживает простой текст, HTML и вложения.
SMTP configuration
You need the SMTP credentials of your email provider. Common settings:
| Provider | Server | Port |
|---|---|---|
| Gmail | smtp.gmail.com | 587 |
| Outlook | smtp-mail.outlook.com | 587 |
| Custom | your SMTP server | 587 or 465 |
The complete script
from seatable_api import Base, context
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
base = Base(context.api_token, context.server_url)
base.auth()
# SMTP configuration
SMTP_SERVER = "smtp.example.com"
SMTP_PORT = 587
SMTP_USER = "your-email@example.com"
SMTP_PASSWORD = "your-password"
# Email settings
RECIPIENT = "recipient@example.com"
SUBJECT = "Automated email from SeaTable"
BODY = "This is an automated email sent from a SeaTable Python script."
msg = MIMEMultipart()
msg['From'] = SMTP_USER
msg['To'] = RECIPIENT
msg['Subject'] = SUBJECT
msg.attach(MIMEText(BODY, 'plain'))
with smtplib.SMTP(SMTP_SERVER, SMTP_PORT) as server:
server.starttls()
server.login(SMTP_USER, SMTP_PASSWORD)
server.send_message(msg)
print(f"Email sent to {RECIPIENT}")
You can extend this script to read recipients, subjects, or email content from your SeaTable tables using base.list_rows(). For HTML emails, replace 'plain' with 'html' in the MIMEText call.
For the complete function reference, visit the SeaTable Developer Manual .