📝 If you have any suggestion, you can open an issue or send me a message with this contact-form !
➡️ View Demo
This is a contact form with Next.js 13 & SendGrid, enabling you to receive emails from your clients easily.
➡️ Stack
➡️ Install locally
➡️ Environnements Variables
➡️ Sendgrid tutorial
🚀 Nextjs13 (Using App Router)
✉️ Sendgrid
🌐 Axios
Install dependencies :
npm installRun the development server:
npm run devTo run this project with SendGrid and receive emails from your clients, you need to create a file named: .env.local
KEY_SENDGRID=YOUR_SECRET_KEY_SENGRID
EMAIL_TO=EMAIL_TO
FROM_EMAIL=FROM_EMAIL
TEMPLATE_ID=YOUR_TEMPLATE_IDIn this part, I'll show you step by step how to setup Sengrid.
- Go to Sendgrid.com
- Create your account
- Signin
On the side bar :
- Email API > Dynamic Templates
- Create a Dynamic Template
- Choose a name > Create
- Design it as you want
- Edit the HTML module like this :
<div style="font-family: inherit; text-align: center; padding: 15px">
<span style="font-size: 15px">Name : {{ name }}</span>
<br>
<span style="font-size: 14px">Firstname : {{ firstname }}</span>
<br>
<span style="font-size: 14px">email : {{ email }}</span>
<br>
<span style="font-size: 16px">message : {{message}}</span>
</div>This is an example; here it's important for you to notice the syntax {{field}}.
Don't forget to obtain your TEMPLATE_ID from the Dynamic Template page. Copy and paste it into the .env.local
On the side bar :
- Settings > API Keys
- Create API Keys
- Choose a name
- Full Acess > Create & View
⚠️ You will see the API_KEY only at this moment- Copy and paste it into the .env.local
On the side bar :
- Settings > Sender Authentication
- Verify a Single Sender
- Create a New Sender
- Complete the form correctly
- Verify you email
- Add the sender email FROM_TO in the .env.local
The receiver is the email address where you want to receive messages.
- Add the receiver email of your choice in EMAIL_TO