Dartvel, home
Docs
Features
Studio
Cloud
Compared

Search the site

GitHub
pub.dev

GETTING STARTED

Getting started
Existing Flutter apps
Existing Native apps
Run on your phone

APP

UI and styling
Routing
State
Accessibility
Keyboard shortcuts
Localization
Devices and desktop
Native device access
Media, 3D and XR

DATA

Data models
Forms
Search
Sync and offline
Import and export
Change capture
Database
Cache
File storage
Images
Privacy and erasure

BACKEND

Backend functions
Auth and sessions
Authorization
Queues and jobs
Workers and memory
Notifications and mail
Outbound HTTP
AI
Webhooks
GraphQL and OpenAPI
API keys and OAuth
Multi-tenancy
Billing and commerce
Modules

OPERATIONS

Edge security
Secrets and environments
Monitoring
Releases

SHIPPING

Build targets
Telegram Mini Apps
Static web hosting
Servers and deploying

REFERENCE

Testing
CLI reference
Coding agents

BACKEND

Notifications and mail

Send email, in-app and push notifications through DV.Notifications.

Mail is part of it, at DV.Notifications.mail.

ON THIS PAGE

Pick a mail provider

Send an email

Notify a person on several channels

Status

Pick a mail provider

void configureMail() {
  DV.Notifications.mail.useProvider(SmtpMailProvider(
    host: 'smtp.example.com',
    username: 'apikey',
    password: DV.Secrets.get('SMTP_PASSWORD'),
  ));
}

Copy code to clipboard

SmtpMailProvider

Sends through: Any SMTP server, port 587 by default

ResendMailProvider

Sends through: Resend

SendGridMailProvider

Sends through: SendGrid

PostmarkMailProvider

Sends through: Postmark

SesMailProvider

Sends through: Amazon SES

MailgunMailProvider

Sends through: Mailgun

DVMemoryMailProvider

Sends through: Nowhere. It keeps messages in .sent for tests

Providers are set in code. Read passwords and API keys with DV.Secrets.get.

Send an email

await DV.Notifications.mail.send(const DVMailMessage(
  from: DVMailAddress('hello@example.com', name: 'Shop'),
  to: <DVMailAddress>[DVMailAddress('ada@example.com')],
  subject: 'Your order shipped',
  text: 'It arrives on Friday.',
));

Copy code to clipboard

Add html: for an HTML body next to the text one.

send throws when no mail provider is set.

Notify a person on several channels

DV.Notifications.register(DVMemoryNotificationProvider());

final DVNotificationDelivery delivery = await DV.Notifications.send(
  'user-1',
  const DVNotificationMessage(
    title: 'Order shipped',
    body: 'It arrives on Friday.',
    channels: <DVNotificationChannel>[DVNotificationChannel.inApp],
  ),
);

Copy code to clipboard

Channels are inApp, email, push, sms and webPush.

Register one provider per kind, such as FirebasePushProvider, ApnsPushProvider, WebPushProvider or TwilioSmsProvider.

useRoutes tells the service each person's address and device tokens.

push tries the native providers first and falls back to Web Push when none is registered or the one that is fails.

usePreferences reads each person's muted channels and quiet hours. Push, web push and SMS are not sent during quiet hours, and email is.

send returns a DVNotificationDelivery with the outcome of every channel, so a muted or unrouted channel is told apart from one that failed.

Status

Partial

Spec section: Mail and Notifications

Planned work and implementation limits

No attachments, bounce webhooks or List-Unsubscribe header.

Mail is sent directly, and not through the job queue.

Desktop and TV push kinds have no implementation.

PREVIOUS Workers and memory Heavy work on other cores, and memory reserved up front
NEXT Outbound HTTP Call APIs you have declared, with retries
GitHub
pub.dev
npm
Acknowledgements
Privacy
Terms

FSL-1.1-MIT licensed. Built with Dartvel.

Dartvel is made by

SigmaDev Digital

To the bottom