Videos
Check out our tutorial video series.
How to compose mail and download emails in Dart or Flutter
Dart is a great programming language from Google that is widely used in cross platform app development. In this post we'll show you how to send and receive emails within Dart code. This can be used in apps to send login emails or in tests to test user sign-up or notifications.
First thing we need to install Dart. On a mac we can use brew like so:
Create a new directory and add a to describe the project and dependencies:
Next we can write a simple test to demonstrate email sending. Let's call it .
Inside the test file import the and
packages.
Next we can use the mailslurp package to configure email sending and receiving. It's free for personal use but requires an API Key.
Then add a setup function:
Next add configuration for MailSlurp:
Disposable email mailboxes are a common need during testing. We can create an inbox using MailSlurp like this:
To send emails use the inbox controller with an inbox ID:
To download emails we can use an instance of the to wait for an expected email in a given inbox:
Dart has many other email abilities. To find out more see the MailSlurp documentation.
Check out our tutorial video series.
Email and SMS guides for automation and testing.
View github project code for multiple languages.
Latest posts from the MailSlurp team.
Test, build, and automate messaging with a free MailSlurp account.