Send email from JavaScript without building a backend
Neuctra Mailer lets your frontend send real email through an SMTP account you already own. Install the @neuctra/mailer SDK, paste four credentials, and call mailer.send() from the browser, React, Next.js or Node.js. There is no mail server or email backend for you to write.
How do I send email from the frontend without a server?
Browsers can't open SMTP connections, so sending email usually means writing a backend route. Neuctra Mailer is that route, already built. Your app calls the SDK, and Neuctra Mailer sends the email through your SMTP login.
- 1Create a Neuctra Mailer account and add a service.
- 2Enter your SMTP login. Quick fill sets the host and port for Gmail, Outlook, Zoho, Amazon SES, Brevo and Mailgun.
- 3Add your website under Allowed websites, so only your site can use the key.
- 4Run npm install @neuctra/mailer and call mailer.send().
A contact form email in React or Next.js
This is all the code a contact form needs. The visitor's address goes in replyTo, so you can answer them straight from your inbox.
import { NeuctraMailer } from "@neuctra/mailer";
const mailer = new NeuctraMailer({
serverUrl: process.env.NEXT_PUBLIC_MAILER_URL,
serviceId: process.env.NEXT_PUBLIC_MAILER_SERVICE_ID,
serviceName: process.env.NEXT_PUBLIC_MAILER_SERVICE_NAME,
apiKey: process.env.NEXT_PUBLIC_MAILER_API_KEY,
});
await mailer.send({
to: "support@myshop.com",
replyTo: form.email,
subject: `New message from ${form.name}`,
text: form.message,
});What you can send
- Plain text, HTML or both, with to, cc, bcc and reply-to
- Up to 50 recipients per email
- Order confirmations, password resets, contact forms and alerts
- Works in any browser app, React, Next.js and Node.js 18+
- TypeScript types included, and readable errors with an HTTP status
Is it safe to put an email API key in frontend code?
Yes, when you list your websites under Allowed websites. Requests from any other origin are refused with a 403. You can rotate the key in one click, and the old key stops working at once. SMTP passwords are encrypted with AES-256-GCM and never sent back to the browser.
If you prefer to keep the key private, call the same SDK from a Next.js route handler or any Node.js server instead.
Use the SMTP account you already have
Emails go out from your own address through your own provider, so replies, sent folders and sending reputation stay yours.
- Gmail and Google Workspace (with an App Password)
- Outlook and Microsoft 365
- Zoho Mail
- Amazon SES
- Brevo and Mailgun
- Any other SMTP server
Frequently asked questions
- Can I send email with JavaScript alone?
- Not directly, because browsers can't connect to SMTP servers. With Neuctra Mailer your JavaScript calls one SDK method and Neuctra Mailer sends the email through your SMTP account, so you don't write a backend.
- Does it work with Gmail?
- Yes. Use smtp.gmail.com on port 465 with SSL, and create a Google App Password to use as the SMTP password.
- How do I know if an email failed?
- The SDK throws a NeuctraMailerError with the HTTP status and the SMTP server's own reason, plus a plain-English hint, so your app can show it or try again.
- Can I test my settings without sending an email?
- Yes. mailer.verify() checks your credentials and logs in to the SMTP server without sending anything.
Send your first email today
Create a service, add your SMTP login and send a test. It takes about two minutes.