A simple example project to demonstrate how to use Nuxt 3, Node.js, and Nodemailer to send emails via a form. This is the first version of this example project, with more thorough explanations to come. A comment-free version will be uploaded to the uncommented
branch shortly.
- Nuxt 3 Integration: Utilizes Nuxt 3 for building a modern web application.
- Email Sending: Uses the Node.js package
nodemailer
to send emails from the server side. - Tailwind CSS: Styled with Tailwind CSS for a modern and responsive design.
- Form Handling: Demonstrates form submission and server-side processing.
To get started with this project, follow these steps:
-
Clone the repository:
git clone https://github.com/thaikolja/nuxt-send-email-example.git cd nuxt-send-email-example
-
Install dependencies listed in
package.json
:yarn install # or bun i; or npm i
-
Set your outgoing email server credentials:
- Google Mail
- Create an "App Password"
- Go to
/server/api/mail/send.post.ts
and changeuser
andpass
on lines 145 and 145, respectively
- Other Providers
- Open the same
send.post.ts
and enter your email account login details - Instead of
provider
, usehost
to define your hostname (i.e.,mail.website.com
) port
may have to be added belowservice
andsecure
switched tofalse
for some servers with invalid certificates.
- Open the same
- Google Mail
- To run the project locally, use the following command:
yarn dev # or bun dev; or npm run dev
-
This will start the Nuxt development server. You can access the application at
http://localhost:3000
. -
Then, fill out the form and click "Send E-Mail" to immediately receive an email to the target (
to
address).
The project uses a basic configuration setup:
- Nuxt Config: Located in
nuxt.config.ts
, it sets up Tailwind CSS and basic meta tags. - Email Sending: Configured in
server/api/email/send.post.ts
usingnodemailer
.
Contributions are welcome! If you have suggestions or improvements, please open an issue or submit a pull request.
- Kolja Nolte kolja.nolte@gmail.com
This project is licensed under the MIT License. See the LICENSE file for details.
- Nuxt.js: For providing a powerful framework for building Vue.js applications.
- Nodemailer: For simplifying email sending in Node.js.
- Tailwind CSS: For offering a utility-first approach to styling.