https://github.com/killshot13/express-smtp-mailer
A production-ready Node backend with an Express SMTP mail server configurable for use with contact forms, subscriptions, etc.
https://github.com/killshot13/express-smtp-mailer
backend backend-services express-js gmail-smtp node-js nodejs nodemailer production-ready smtp-mail smtp-server
Last synced: about 14 hours ago
JSON representation
A production-ready Node backend with an Express SMTP mail server configurable for use with contact forms, subscriptions, etc.
- Host: GitHub
- URL: https://github.com/killshot13/express-smtp-mailer
- Owner: killshot13
- License: mit
- Created: 2020-11-02T05:27:54.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-03-27T20:14:30.000Z (about 1 year ago)
- Last Synced: 2024-10-29T23:14:56.977Z (6 months ago)
- Topics: backend, backend-services, express-js, gmail-smtp, node-js, nodejs, nodemailer, production-ready, smtp-mail, smtp-server
- Language: JavaScript
- Homepage:
- Size: 1.07 MB
- Stars: 40
- Watchers: 0
- Forks: 17
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# express-smtp-mailer
***
| Status | Usage | Tooling | Security | Support |
| :----: | :---: | :-----: | :------: | :-----: |
| [](https://travis-ci.com/killshot13/express-smtp-mailer) | [](https://lbesson.mit-license.org/) | [](https://github.com/prettier/prettier) | [](https://snyk.io/test/github/killshot13/express-smtp-mailer) | [](https://github.com/killshot13/express-smtp-mailer/graphs/traffic) |>ATTENTION: VERSION 2.0.0 HAS BEEN RELEASED. THIS IS A MAJOR SERMVER VERSIONING UPDATE AKA INCLUDES BREAKING CHANGES. PLEASE BE AWARE AND DON'T HESITATE TO REACH OUT IF YOU ARE EXPERIENCING NEGATIVE SIDE-EFFECTS FROM THE LATEST UPDATE.
## [VIEW PROJECT CHANGELOG](https://github.com/killshot13/express-smtp-mailer/wiki/Version-Release-Notes)
## [READ STEP-BY-STEP WALKTHROUGH](https://daily.dev/posts/how-to-build-an-smtp-mail-server-with-express-node-and-gmail)### Installation
`git clone` this repository
`cd express-smtp-mailer` to enter root directory
`npm install` to acquire the `node_modules`
`code .` to open VS Code (or your favorite editor)
### Configuration
create a new `.env` file in the root directory
use the `process.env` variables defined in the `.env.example` and `./routes/mailrouter.js` files to setup authentication
for development and testing, create an [Ethereal account](https://ethereal.email/create) and enter the credentials of the testing account (if desired)
_`process.env.SMTP_DEV_EMAIL=''`_
_`process.env.SMTP_DEV_PASSWORD=''`_
for production, you need to create a project on Google Cloud Platform, create an internal project, authorize the Gmail API, and then establish a connection with your Google account. You can [authenticate using OAuth 2.0](https://cloud.google.com/docs/authentication) via the Google API Playground, and once you perform the initial authentication and accept the request permissions, Nodemailer will take over and automatically renew your login so it doesn't actually expire in production.
clientId: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET,
refreshToken: process.env.REFRESH_TOKEN,
accessToken: process.env.ACCESS_TOKEN,### Testing
go back to the terminal and run `npm run dev`
it should print out the following lines
`Node dev server: listening on port 5000`
`Ready to send mail!`
verify full functionality by replacing `'./frontend/frontend.js'` with your own API routes and linking them to the endpoints defined in `./routes/mailrouter.js` and `./server.js`
### Success
and there you have it!
a deployment-ready express smtp mail server