2025-12-03 19:56:35 -03:00
|
|
|
# SEND MAIL
|
|
|
|
|
|
2025-12-18 16:18:04 -03:00
|
|
|
Send email messages.
|
2025-12-03 19:56:35 -03:00
|
|
|
|
|
|
|
|
## Syntax
|
|
|
|
|
|
|
|
|
|
```basic
|
|
|
|
|
SEND MAIL to, subject, body
|
2025-12-18 16:18:04 -03:00
|
|
|
SEND MAIL to, subject, body USING "account@example.com"
|
2025-12-03 19:56:35 -03:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Parameters
|
|
|
|
|
|
|
|
|
|
| Parameter | Type | Description |
|
|
|
|
|
|-----------|------|-------------|
|
|
|
|
|
| `to` | String | Recipient email address(es), comma-separated for multiple |
|
|
|
|
|
| `subject` | String | Email subject line |
|
|
|
|
|
| `body` | String | Email body (plain text or HTML) |
|
2025-12-18 16:18:04 -03:00
|
|
|
| `account` | String | (Optional) Connected account to send through |
|
2025-12-03 19:56:35 -03:00
|
|
|
|
|
|
|
|
## Description
|
|
|
|
|
|
2025-12-18 16:18:04 -03:00
|
|
|
The `SEND MAIL` keyword sends emails using either:
|
2025-12-03 19:56:35 -03:00
|
|
|
|
2025-12-18 16:18:04 -03:00
|
|
|
1. **Default SMTP** - Configuration from `config.csv`
|
|
|
|
|
2. **Connected Account** - Send through Gmail, Outlook, etc. configured in Sources app
|
2025-12-03 19:56:35 -03:00
|
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
|
2025-12-18 16:18:04 -03:00
|
|
|
Default SMTP in `config.csv`:
|
2025-12-03 19:56:35 -03:00
|
|
|
|
|
|
|
|
```csv
|
|
|
|
|
name,value
|
|
|
|
|
email-from,noreply@example.com
|
|
|
|
|
email-server,smtp.example.com
|
|
|
|
|
email-port,587
|
|
|
|
|
email-user,smtp-user@example.com
|
|
|
|
|
email-pass,smtp-password
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
|
|
```basic
|
|
|
|
|
SEND MAIL "user@example.com", "Welcome!", "Thank you for signing up."
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
```basic
|
2025-12-18 16:18:04 -03:00
|
|
|
recipients = "john@example.com, jane@example.com"
|
2025-12-03 19:56:35 -03:00
|
|
|
SEND MAIL recipients, "Team Update", "Meeting tomorrow at 3 PM"
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
```basic
|
|
|
|
|
body = "<h1>Welcome!</h1><p>Thank you for joining us.</p>"
|
|
|
|
|
SEND MAIL "user@example.com", "Getting Started", body
|
|
|
|
|
```
|
|
|
|
|
|
2025-12-18 16:18:04 -03:00
|
|
|
## USING Clause
|
2025-12-03 19:56:35 -03:00
|
|
|
|
2025-12-18 16:18:04 -03:00
|
|
|
Send through a connected account configured in Suite → Sources → Accounts:
|
2025-12-03 19:56:35 -03:00
|
|
|
|
|
|
|
|
```basic
|
2025-12-18 16:18:04 -03:00
|
|
|
SEND MAIL "customer@example.com", "Subject", body USING "support@company.com"
|
2025-12-03 19:56:35 -03:00
|
|
|
```
|
|
|
|
|
|
2025-12-18 16:18:04 -03:00
|
|
|
The email appears from that account's address with proper authentication.
|
2025-12-03 19:56:35 -03:00
|
|
|
|
|
|
|
|
```basic
|
2025-12-18 16:18:04 -03:00
|
|
|
SEND MAIL "customer@example.com", "Ticket Update", "Your ticket has been resolved." USING "support@company.com"
|
2025-12-03 19:56:35 -03:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Delivery Status
|
|
|
|
|
|
|
|
|
|
```basic
|
|
|
|
|
status = SEND MAIL "user@example.com", "Test", "Message"
|
|
|
|
|
IF status = "sent" THEN
|
|
|
|
|
TALK "Email delivered successfully"
|
|
|
|
|
END IF
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Best Practices
|
|
|
|
|
|
2025-12-18 16:18:04 -03:00
|
|
|
1. Use connected accounts for better deliverability
|
|
|
|
|
2. Validate email addresses before sending
|
|
|
|
|
3. Implement delays for bulk emails
|
|
|
|
|
4. Handle failures gracefully
|
2025-12-03 19:56:35 -03:00
|
|
|
|
|
|
|
|
## Troubleshooting
|
|
|
|
|
|
2025-12-18 16:18:04 -03:00
|
|
|
| Issue | Cause | Solution |
|
|
|
|
|
|-------|-------|----------|
|
|
|
|
|
| Auth failed | Invalid credentials | Check config.csv or re-authenticate account |
|
|
|
|
|
| Not sending | Firewall blocking | Verify port 587/465 is open |
|
|
|
|
|
| Going to spam | No domain auth | Configure SPF/DKIM |
|
|
|
|
|
| Account not found | Not configured | Add account in Suite → Sources |
|
2025-12-03 19:56:35 -03:00
|
|
|
|
2025-12-18 16:18:04 -03:00
|
|
|
## See Also
|
2025-12-03 19:56:35 -03:00
|
|
|
|
2025-12-18 16:18:04 -03:00
|
|
|
- [USE ACCOUNT](./keyword-use-account.md)
|
|
|
|
|
- [WAIT](./keyword-wait.md)
|
2025-12-03 19:56:35 -03:00
|
|
|
|
|
|
|
|
## Implementation
|
|
|
|
|
|
|
|
|
|
Located in `src/basic/keywords/send_mail.rs`
|