dox_mailer 3.2.4
dox_mailer: ^3.2.4 copied to clipboard
Send email from the Dox framework: SMTP, Amazon SES, Azure, Resend, Mailgun, Postmark, Cloudflare and sendmail.
3.2.4 #
- New:
CloudflareTransport(accountId:, apiToken:)sends with the Cloudflare Email Service API.dox mailer:install --transport=cloudflaresets it up and adds theCLOUDFLARE_ACCOUNT_IDandCLOUDFLARE_API_TOKENkeys. - Faster: the HTTP transports read and write JSON as bytes. They do not make a String of the full body.
3.2.3 #
- Faster: the HTTP transports (Resend, SES, Mailgun, Postmark, Azure) send through the native client of dox_http_client. It uses HTTP/2 when the server has it. A
clientthat you pass is used as before.
3.2.2 #
- Fix: an email address, attachment cid or content type with a character that is not ASCII now throws a
MailException. Before, SES threw anArgumentError, so a queued mail failed on every retry. Display names, subjects and file names can still be any text: they are encoded. - Note: a non-ASCII email address, like
user@münchen.de, is refused on every transport. Write the domain in punycode instead, likeuser@xn--mnchen-3ya.de.
3.2.1 #
- Change: the log line when an
onSenthook throws now starts with[mail](wasMail:).
3.2.0 #
- New
dox mailer:install [--transport=log|smtp|resend|mailgun|postmark|ses], run bydox add mailer. It writeslib/config/mail.dartand the provider, adds theMAIL_*keys, and makesresources/views/emailswhen the app hasdox_view. It never overwrites a file. - Breaking: the queued mail classes
SendQueuedMail,SendEncryptedQueuedMail,RedactedMailErrorandQueueMailQueueare now in dox_mailer. Import them frompackage:dox_mailer/dox_mailer.dart, not from dox_queue. The saved job names staydox_queue:SendQueuedMailanddox_queue:SendEncryptedQueuedMail. - Breaking: dox_mailer now depends on dox_queue.
Mail.mailQueuefalls back toQueueMailQueue, soMail.queue()andMail.later()use the dox_queue queue by default. There is noStateErrorwhen no queue was set.Mail.useQueue(null)goes back to it. The app needs theQueueProviderand a worker.- The mail jobs are in
lib/generated/jobs.g.dartwhen the app runsbuild_runnerwith the dox_builder release that has the job builder.Mail.configure()still adds them too, as a fallback. Abin/queue.dartworker still needsMailProviderin its providers: the mail job sends with the mail config. Without it the job fails with "Mail is not set up" (before, with an unknown job name). - Breaking: dox_mailer does not import
dox_coreany more.dox_viewstill uses it.MailProviderusesDoxProviderfromdox_annotation. - Breaking: the log transport always prints with
print.LogTransport(useLogger:)is removed. AnonSenthook error goes tostderr, not to the DoxLogger. - Ships an AI agent skill (dox-mailer-guide). Install it in your app with
dart run skills@ get. - New:
LogTransport(bothBodies: true)shows the text body and the HTML body when an email has both. - Fix: when an
onSenthook threw and the logger also threw anException(not anError),send()failed after the email was sent. Now the error goes to stderr, andsend()does not throw. - Fix: when an
onSenthook threw in a queue worker withtriesabove 1, the job failed after the email was sent. The worker then sent the email again. Now anonSenterror is logged andsend()does not throw. The otheronSenthooks still run. - Docs: start
setup()withMail.clearHooks(). Hooks are kept in a list, so whensetup()runs twice in one isolate, each hook runs twice.
3.1.0 #
- Fix: in a Markdown mail,
{{ }}escaped HTML but not Markdown. So a user value like[Verify](https://evil.example)became a real link. Now a text value ofdatastays text: backslash, backtick,*,[,],#and|in it are not Markdown. This counts for text in maps, lists, sets and objects withtoJson()too. To put Markdown from a value, pass aSafeString. In@if, a value with one of these characters is no longer equal to the same text written in the template. - Fix: in a Markdown mail,
{{ tag }}inside backticks was escaped twice, so<b>showed as<b>. Now it shows as<b>. - Fix: in
FailoverTransport, anasynconErrorthat throws gave an uncaught error. Now its error is ignored too. It is not awaited. - New:
Mail.onSending()andMail.onSent()hooks run before and after each email is sent.Mail.clearHooks()removes them. - New:
Mail.alwaysTo(address)sends every email to one address, eg. on staging.ccandbccare cleared.Mail.alwaysTo(null)turns it off. - New:
Mail.raw(text, to: 'ann@example.com', subject: 'Hi')sends a plain text email.Mail.to('ann@example.com').cc(...).bcc(...).send(mailable)adds recipients with chained calls. It also hasqueue(),later()andraw(). Addresses can be plain email text.Address.list()reads anAddress, an email text, or a list of these. - Docs: how to attach a file from a storage disk, with
Attachment(bytes, name). - Fix: in
FailoverTransport, anonErrorcallback that throws stopped the failover, so the next transports were never tried. Now an error fromonErroris ignored: the next transport is still tried, and the send error is thrown as before. - Fix: the
assertSentCounterror said "Expected 1 sent emails". Now it says "Expected 1 sent email". - Docs: with both
Mail.fake()andQueue.fake()on,Mail.fake()catches queued emails first. - Fix:
Attachment.fromFileread the file with a blocking call, which stops the server for every other request while it reads. Now the file is read without blocking when the message is sent or queued. A missing file now throws itsFileSystemExceptionfromsend()(orqueue()), not fromfromFile. Readingbytesbefore that still works: it reads the file then. - With
Attachment.fromFile, the file is read when the message is sent or queued, not whenfromFileruns. A file that changed betweenfromFileandsend()now sends the new content. A file that was deleted fails atsend(). - New: check methods on the
ArrayTransportofMail.fake():assertSent,assertSentCount,assertNotSent,assertNothingSent,assertQueued,assertNotQueuedandassertNothingQueued. Each one can take a test function that gets theMessage. A failed check throws aStateErrorthat lists the emails. - New:
Mail.fake()catchesMail.queue()andMail.later()too, also thequeue()andlater()of mailables and queued notifications. The email goes to the newqueuedlist of theArrayTransport, as aQueuedMessagewith the mailer name, the delay, the queue name andencrypt. No job is pushed, so a test needs no queue. - New: mailables. A
Mailableis one kind of email in its own class:to,subject,view,data,attachmentsand more. Send it withsend(), or put it on the queue withqueue()andlater(). The body can come from a dox_view template (view,textView) or from plain text (html,text). - New: Markdown mail. The
markdowngetter of a mailable names a dox_view template with Markdown. The HTML body is the Markdown inside a simple layout (overridelayout()for your own). The text body is the Markdown. The Markdown is CommonMark with tables, like Laravel mail, so a bare URL stays text: write<url>or[text](url). Links and images with an unsafe URL (likejavascript:ordata:) lose their URL. Onlyhttp,https,mailto,tel,cidand relative URLs are kept. - New:
MailMessage, a mailable made of lines and a button, with no template. It also hascc,attach()anderror()(red buttons).action()throws anArgumentErrorfor an unsafe URL, likejavascript:. - New: notifications. A
Notificationpicks its channels invia().MailChannelsends thetoMail()email, or queues it whenshouldQueueis true (with thequeue,delayandencryptgetters). The mail route can be anAddress, an email text, or a list of these. AddNotifiableto the user class and calluser.notify(notification), orNotification.send(users, notification). Write your own channel (eg. a database channel) withNotificationChannelandtoArray(). When a channel fails,Notification.send()still sends to the others, then throws aNotificationExceptionwith every error. With one notifiable and one error (likeuser.notify()), it throws that error as it is. - dox_mailer now uses dox_view and markdown.
- New:
Mail.queue(message)andMail.later(delay, message). They put the email on the job queue, so the request does not wait. A queue worker sends it later.Mail.mailer('ses').queue()and.later()keep the mailer, so the worker uses the same transport. Options:queue(the queue name) andencrypt(save the job data encrypted). The message is checked when it is queued. This needs dox_queue, which sets the queue inQueue.configure(). - New:
Message.toJson()andMessage.fromJson(), also onAddressandAttachment. Attachments are saved as base64. - New: the
MailQueueinterface andMail.useQueue(), so a queue package (or a test) can take queued emails.
3.0.0 #
- The first stable release.
3.0.0-rc.1 #
- Docs: README and
docs/mail.mdnow say "provider", not "service", forMailProvider.
3.0.0-alpha.2 #
MailProvider(was a DoxService): extend it in your app,shutdown()is optional.
3.0.0-alpha.1 #
- First version.
Mail.send()andMail.mailer('name').send(), with a default mailer and named mailers inMailConfig.Messagewith from, to, cc, bcc, reply-to, subject, text, HTML, attachments, inline images, custom headers, tags and metadata.- Transports: SMTP, Amazon SES (v1 and v2 API), Azure Communication Services, Resend, Mailgun, Postmark, sendmail, log, array (for tests) and failover.
- One MIME builder for SMTP, SES and sendmail.
- AWS Signature Version 4, with no AWS SDK.
MailServicesets up the mailers in every isolate.Mail.fake()for tests.