A guide to using the mailer package
When an important event happens on your Dart server, it would be nice to get a notification. One way to do that is to send yourself an email. This article will cover how to do that using the mailer package.
You’ll create a simple Dart server where every time someone makes a POST request to the /contact
endpoint, Mailer will send you an email containing the body of the POST.
You can find the full code at the bottom of the article.
What is SMTP?
The way Mailer works is by helping you connect to an SMTP server, but that begs the question, “What’s an SMTP server?”
SMTP stands for Simple Mail Transfer Protocol, and just like HTTP is a protocol (or set of rules) for transferring web traffic, SMTP is a protocol for transferring email. So an SMTP server is an email server. It’s used for sending email, but not receiving it. IMAP and POP3 are protocols for receiving email.
Creating the basic server
Before adding the Mailer package, first make a basic Dart server that accepts POST requests.
Start with a new Dart project:
dart create my_server