TrashMail is a web application for generating disposable/temporary email addresses and viewing emails sent to those addresses. The project consists of a React frontend and a Node.js and MongoDB backend mail server.
The React frontend provides the user interface for generating disposable emails, viewing the inbox, and reading emails.
- Generate a random disposable email address
- Enter a custom disposable email address
- View all received emails for an address
- Read a specific email and attachments
- Delete emails
- Responsive design
- React
- React Router
- Material UI
- Axios
- Home: Explains the service and contains buttons to generate or enter an email
- Inbox: Lists received emails for an address
- Email: Displays the content of a specific email
cd react
npm install
npm start
The frontend will run on http://localhost:3000
The Node.js backend provides the mail server functionality for receiving emails via SMTP and managing emails via a REST API.
- SMTP server to receive emails
- Save emails and attachments to MongoDB database
- Retrieve emails for an address
- Delete emails
- Serve attachment files
- Node.js
- Express
- MongoDB
- SMTP Server
- Mailparser
GET /emails/:emailId
- Get emails for an addressGET /emails-list/:emailId
- Get email listGET /all-emails
- Get all emailsGET /email/:emailId/:email_id
- Get specific emailDELETE /email/:emailId/:email_id
- Delete email
cd server
npm install
Edit config.js
to configure SMTP port, MongoDB URL, etc.
node server.js
The backend will run on port 4000
The frontend and backend can be deployed separately. The React frontend can be built and served using any web server. The Node.js backend can be deployed to a server or hosting service like AWS or Home Server like Raspberry Pi with port forwarding. Make sure to configure the frontend to point to the correct backend URL.
For those who prefer a containerized deployment, Docker can be used to easily set up and run TrashMail. The repository includes a Dockerfile to simplify this process.
-
Build the Docker Image: Ensure you are in the root directory of the project and run:
docker build -t trashmail-app .
-
Run the Docker Container: After building the image, you can start the container using:
sudo docker run -d -p 4000:4000 -p 25:25 -v ./attachments:/Trashmail/mailserver/attachments -e REACT_APP_API_URL= -e REACT_APP_DOMAINS='["example.com"]' --name trashmail-container enkidu6/Trashmail:latest
This command starts the TrashMail application and exposes it on ports 4000 and 25 for mailserver.
-
Accessing the Application: Once the container is running, you can access the frontend at http://localhost:3000 and the backend on port 4000.
Ensure you have Docker installed and running on your machine before executing these commands.
Option/Variable | Description |
---|---|
-e REACT_APP_API_URL= |
Sets the API URL. Leave empty or set to the backend URL if hosted externally. Example: -e REACT_APP_API_URL=http://backendhost:4000 |
-e REACT_APP_DOMAINS='["example.com", "example.org"]' |
Specifies the domains for the email service. Set to desired domains. |
-v ./attachments:/Trashmail/mailserver/attachments |
Volume mount for attachments. Maps a local directory to a container directory. |
-v /my/local/mongodb:/data/db |
(Optional) Volume mount for MongoDB data. Maps a local directory to the MongoDB data directory in the container. |
These options and environment variables are crucial for configuring the TrashMail application within the Docker environment, especially for handling backend API communication and data persistence.
This application demonstrates a disposable email service with basic functionality like inbox and reading emails. Additional features like registering custom domains, tagging emails, search, etc. can be added.
If you encounter any issues or have any questions or suggestions, please open an issue in the GitHub repository.
Thanks to the contributors of the libraries used in this project for their excellent work.