https://github.com/bahmutov/cypress-sendgrid-mailosaur-example
Sending and testing email flows example
https://github.com/bahmutov/cypress-sendgrid-mailosaur-example
cypress-example
Last synced: 9 months ago
JSON representation
Sending and testing email flows example
- Host: GitHub
- URL: https://github.com/bahmutov/cypress-sendgrid-mailosaur-example
- Owner: bahmutov
- Created: 2022-12-13T23:00:34.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-09-24T02:15:41.000Z (9 months ago)
- Last Synced: 2025-09-24T04:12:28.445Z (9 months ago)
- Topics: cypress-example
- Language: JavaScript
- Homepage: https://glebbahmutov.com/blog/cypress-mailosaur/
- Size: 281 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# cypress-sendgrid-mailosaur-example  [](https://github.com/bahmutov/cypress-sendgrid-mailosaur-example/actions/workflows/ci.yml)
> Sending and testing email flows example
Read 📝 [Testing Email Flow Using Cypress and Mailosaur](https://glebbahmutov.com/blog/cypress-mailosaur/) and [Minimize Mailosaur Use](https://glebbahmutov.com/blog/minimize-mailosaur-use/).
- Sending emails via Sendgrid
- Fetching sent emails using [cypress-mailosaur](https://github.com/mailosaur/cypress-mailosaur)
- End-to-end testing using Cypress

## Prerequisites
SendGrid account with API key and a verified email sender, see [this doc](https://sendgrid.com/docs/for-developers/sending-email/quickstart-nodejs/). Similarly you need Mailosaur server ID and API key.
## Install
```shell
$ npm install
```
## Run
Start the server locally with injected `SENDGRID_API_KEY` and `SENDGRID_FROM` environment variables.
```
SENDGRID_API_KEY=... SENDGRID_FROM=... npm start
```
**Tip:** use [as-a](https://github.com/bahmutov/as-a) utility. Put the environment variables into `.as-a.ini` file and give it the same section name as the folder name.
```ini
; http://github.com/bahmutov/as-a
[cypress-sendgrid-mailosaur-example]
; sending emails
SENDGRID_API_KEY=...
SENDGRID_FROM=...
; checking emails
CYPRESS_MAILOSAUR_SERVER_ID=...
CYPRESS_MAILOSAUR_API_KEY=...
```
Start the local application and open Cypress using [start-server-and-test](https://github.com/bahmutov/start-server-and-test) utility
```text
$ as-a . npm run local
```
## See also
- 💻 [Full End-to-End Testing for Your HTML Email Workflows](https://slides.com/bahmutov/email-testing) presentation
- 📝 [Testing email flows with Mailosaur](https://filiphric.com/testing-email-flows-with-mailosaur)
## Small print
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com> © 2022
- [@bahmutov](https://twitter.com/bahmutov)
- [glebbahmutov.com](https://glebbahmutov.com)
- [blog](https://glebbahmutov.com/blog)
- [videos](https://www.youtube.com/glebbahmutov)
- [presentations](https://slides.com/bahmutov)
- [cypress.tips](https://cypress.tips)
- [Cypress Tips & Tricks Newsletter](https://cypresstips.substack.com/)
- [my Cypress courses](https://cypress.tips/courses)
License: MIT - do anything with the code, but don't blame me if it does not work.
Support: if you find any problems with this module, email / tweet /
[open issue](https://github.com/bahmutov/cypress-sendgrid-mailosaur-example/issues) on Github
## MIT License
Copyright (c) 2022 Gleb Bahmutov <gleb.bahmutov@gmail.com>
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.