https://github.com/trapcodeio/api2mailer-server
Api 2 Mailer Server
https://github.com/trapcodeio/api2mailer-server
Last synced: 3 months ago
JSON representation
Api 2 Mailer Server
- Host: GitHub
- URL: https://github.com/trapcodeio/api2mailer-server
- Owner: trapcodeio
- Created: 2021-02-19T07:43:52.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-02-19T16:05:44.000Z (over 4 years ago)
- Last Synced: 2025-03-20T05:34:53.604Z (3 months ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Api2Mailer
This package enables you to test remote `smtp/mailer` functionality from localhost without changing nodemailer's Api.
## What is included?
- A web server. (This Repo)
- An importable package. [api2mailer](https://npmjs.com/package/api2mailer)### Web Server
This webserver should be hosted on the same server your main project is using.
It takes in nodemailer's `sendMail` data via post request and sends the mail on the server.
#### Hosting the server.
- clone this repo
- run `npm install` or `yarn install`
- run `node api2mailer cli @makeConfig` (Creates env.json)Env.json Example:
```json
{
"port": 2222,
"transporters": {
"default": {
"host": "smtp.mailtrap.io",
"port": 2525,
"auth": {
"user": "",
"pass": ""
}
}
}
}
```#### Start Server
```shell
node api2mailer
# OR using pm2
pm2 start api2mailer.js
```This will start a server at `http://localhost:2222` or using your desired port.
### Sending Mail to Server
```js
// Example of how you send mail using `nodemailer`
const nodemailer = require('nodemailer')
const transporter = nodemailer.createTransport({/* Transporter Settings */})
await transporter.sendMail({/* Mail Options */});// Example of how you send mail using `api2mailer`
const nodemailer = require('api2mailer')
const transporter = nodemailer.createTransport({/* Transporter Settings */})
await transporter.sendMail({/* Mail Options */});
```The difference between both is: `api2mailer` proxies your data to your `api2mailer-server` endpoint which then sends
your mail on the remote server.