Send emails from your handlers using SMTP.
{
"service_type": "email",
"config": {
"host": "smtp.example.com",
"port": 587,
"username": "sender@example.com",
"password": "app-password",
"encryption": "starttls",
"from_address": "noreply@example.com",
"from_name": "My App",
"reply_to": "support@example.com"
}
}
{
"service_type": "email",
"config": {
"host": "smtp.gmail.com",
"port": 587,
"username": "your-email@gmail.com",
"password": "your-app-password",
"encryption": "starttls",
"from_address": "your-email@gmail.com",
"from_name": "Your Name"
}
}
{
"service_type": "email",
"config": {
"host": "smtp.example.com",
"port": 465,
"username": "sender@example.com",
"password": "secret",
"encryption": "tls",
"from_address": "noreply@example.com"
}
}
{
"service_type": "email",
"config": {
"host": "localhost",
"port": 25,
"encryption": "none",
"from_address": "app@localhost"
}
}
Field Type Default Description
hoststring required SMTP server hostname
portu16 587 SMTP port
usernamestring null Auth username (usually email address)
passwordstring null Auth password or app password
encryptionstring "starttls" Encryption: "none", "starttls", or "tls"
from_addressstring required Default sender email
from_namestring null Default sender display name
reply_tostring null Default reply-to address
timeout_secondsu32 30 Connection timeout
max_retriesu32 3 Send retry attempts
#![allow(unused)]
fn main() {
use rust_edge_gateway_sdk::prelude::*;
fn handle(req: Request) -> Response {
let email = EmailPool { pool_id: "notifications".to_string() };
let result = email.send(
"user@example.com",
"Welcome!",
"Thanks for signing up.",
);
match result {
Ok(()) => Response::ok(json!({"sent": true})),
Err(e) => Response::internal_error(e.to_string()),
}
}
}
#![allow(unused)]
fn main() {
fn handle(req: Request) -> Response {
let email = EmailPool { pool_id: "notifications".to_string() };
let html = r#"
<h1>Welcome!</h1>
<p>Thanks for joining us.</p>
<a href="https://example.com/verify">Verify your email</a>
"#;
let result = email.send_html(
"user@example.com",
"Welcome to Our App",
html,
);
match result {
Ok(()) => Response::ok(json!({"sent": true})),
Err(e) => Response::internal_error(e.to_string()),
}
}
}
#![allow(unused)]
fn main() {
let result = email.send_from(
"support@example.com", // From
"Support Team", // From name
"user@example.com", // To
"Your Ticket #123", // Subject
"We've received your support request...",
);
}
Provider Host Port Encryption
Gmail smtp.gmail.com 587 starttls
Outlook smtp.office365.com 587 starttls
SendGrid smtp.sendgrid.net 587 starttls
Mailgun smtp.mailgun.org 587 starttls
Amazon SES email-smtp.{region}.amazonaws.com 587 starttls
Use app passwords - Don't use your main account password
Set up SPF/DKIM - Improve deliverability
Handle failures - Emails can fail; log and retry
Rate limit - Don't spam; respect provider limits
Use templates - Consistent formatting
Test with sandbox - Use test mode before production