https://github.com/lightxlk/nlk-smtp-api
A minimal Next.js API for sending contact form submissions to Gmail using Nodemailer, deployable on Vercel /Netlify.
https://github.com/lightxlk/nlk-smtp-api
api json nextjs nodejs nodemailer react smtp typescript vercel
Last synced: 3 months ago
JSON representation
A minimal Next.js API for sending contact form submissions to Gmail using Nodemailer, deployable on Vercel /Netlify.
- Host: GitHub
- URL: https://github.com/lightxlk/nlk-smtp-api
- Owner: lightxLK
- License: agpl-3.0
- Created: 2025-08-18T16:53:06.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-08-28T17:59:12.000Z (10 months ago)
- Last Synced: 2025-08-29T00:14:08.899Z (10 months ago)
- Topics: api, json, nextjs, nodejs, nodemailer, react, smtp, typescript, vercel
- Language: TypeScript
- Homepage: https://nlk-smtp-api-endpoint.vercel.app
- Size: 31.1 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# N&N SMTP Contact API
This is a minimal Next.js API project for handling contact form submissions via email using Gmail SMTP and Nodemailer, developed by Lokesh.
It is designed to be deployed on Vercel /Netlify and used as a backend endpoint for static or dynamic websites.
---
## Features
- Accepts POST requests at `/api/contact`
- Sends contact form details to your Gmail inbox using Nodemailer
- CORS enabled for requests from your frontend domain
---
## Usage
### 1. **Environment Variables**
Set these in your Vercel/Netlify project settings:
- `GMAIL_USER` – Your Gmail address (e.g. `lokesh@thesocialants.com`)
- `GMAIL_PASS` – Your Gmail App Password (see [Gmail App Passwords](https://support.google.com/accounts/answer/185833))
### 2. **API Endpoint**
Send a POST request to:
```
https://.vercel.app/api/contact
```
**Request body (JSON):**
```json
{
"name": "Your Name",
"email": "your@email.com",
"phone": "1234567890",
"subject": "Subject",
"message": "Your message"
}
```
### 3. **CORS**
This API allows requests from `https://nlk.thesocialants.com` by default.
To change, edit the `Access-Control-Allow-Origin` header in `src/pages/api/contact.ts`.
---
## Local Development
1. Clone the repo
2. Install dependencies:
```
npm install
```
3. Add a `.env.local` file:
```
GMAIL_USER=your@gmail.com
GMAIL_PASS=your-app-password
```
4. Run locally:
```
npm run dev
```
---
## Security
- **Never commit your Gmail password or app password to the repo.**
- Always use environment variables for sensitive data.
---
## License
GNU Affero V3
---
**Contact:**
For questions, reach out to [lokesh@thesocialants.com](mailto:lokesh@thesocialants.com) | [light](https://lightxlk.github.io/)