This repository contains a full-stack application that demonstrates how to send emails from an Angular frontend using a Node.js backend and Nodemailer.
- Angular Material UI: Clean and responsive user interface for composing emails.
- Node.js & Express: A lightweight server to handle email requests.
- Nodemailer: Integrated SMTP transport for reliable email delivery.
- CORS Enabled: Ready for cross-origin communication between frontend and backend.
- Frontend: Angular
- Backend: Node.js, Express.js
- Email Library: Nodemailer
angular-email-sender-with-nodejs/
├── backend/ # Express Server
│ ├── app.js # Main API logic
│ └── package.json # Backend dependencies
└── frontend/ # Angular App
├── src/ # Angular source files
└── package.json # Frontend dependencies
- Node.js (LTS version)
- Angular CLI (
npm install -g @angular/cli)
git clone [https://github.com/lipiprajapati/angular-email-sender-by-nodejs.git](https://github.com/lipiprajapati/angular-email-sender-by-nodejs.git)
cd angular-email-sender-by-nodejsNavigate to the backend folder and install dependencies:
cd backend
npm installConfigure your email credentials: Open app.js (or your config file) and update the Nodemailer transporter with your details:
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: 'your-email@gmail.com',
pass: 'your-app-password' // Use an App Password if using Gmail
}
});Start the server:
node server.jsThe backend will typically run on http://localhost:3000.
Navigate to the frontend folder and install dependencies:
cd ../frontend
npm installStart the Angular app:
ng serveOpen your browser and navigate to http://localhost:4200.
Fill out the "To", "Subject", and "Message" fields in the web form.
Click the Send button.
The Angular app sends a POST request to the Node.js backend.
The backend uses Nodemailer to dispatch the email and returns a success or error message.
If you are using Gmail, you must use an App Password rather than your regular account password. Ensure "Less Secure Apps" access is handled or use OAuth2 for production environments.
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project.
- Create your Feature Branch:
git checkout -b feature/AmazingFeature
- Commit your Changes:
git commit -m 'Add some AmazingFeature' - Push to the Branch:
git push origin feature/AmazingFeature
- Open a Pull Request.
Distributed under the MIT License. See LICENSE for more information.