GoDaddy Node.js 호스팅 Help

Send email using Node.js Hosting

Node.js Hosting comes with an email gateway you can use to send transactional emails, contact form notifications, sign-up confirmations, password resets, and receipts, straight from your code. You don’t need an SMTP server, username, password, or third-party email service. Your code sends an HTTP request to the gateway, and the gateway handles delivery for you.

Note: This article covers an advanced topic for informational purposes only. If you require support for your email code, you'll need to contact your developer.

Select a link to see its answer:

How does Node.js Hosting email work?

Your app sends a POST request with a JSON body to the endpoint, http://127.0.0.1:2525/api/email/send. The gateway will check the message, build the email, and deliver it. The gateway can only be reached from your app’s code. It can’t be reached from the internet, from your browser, or from your own computer.

맨 위로

How can I send email?

You'll need to create a file on your server and call it. Below is an example you can use.

Note: Be sure to update the example code to your app or site
const response = await fetch("http://127.0.0.1:2525/api/email/send", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({
    to: ["you@example.com"],
    subject: "Hello from my Node.js app",
    text: "It works! This email was sent from my app on GoDaddy Node.js Hosting.",
  }),
});

const result = await response.json();
console.log(result); // { success: true, messageId: "..." }

맨 위로

Email code requirements and options

Below are email code requirements and some common optional fields you can include.

필드필수설명
to예Recipient addresses. At least one is required.
subject예The subject line
text or htmlAt least one (both are ok)Text or HTML body
cc아니요Carbon-copy recipients
bcc아니요Blind-copy recipients
replyTo아니요Where replies go (for example, the visitor that filled out a contact form)
attachments아니요Files to attach
contentType아니요How to interpret attached files
from아니요Sender address. A default user will be used if left blank. For the best reliability, enter an email address that uses the same domain as your Node.js Hosting and can receive messages (for example, jane@coolexample.com).

맨 위로

How do attachments work?

When sending email with attachments, there are requirements to keep mind.

필드필수설명
filename예The file name the recipient sees (for example, invoice.pdf)
content예The file’s contents.
contentType아니요The MIME type.

When sending email with attachments, there are requirements to keep in mind.

  • Maximum 10 attachments per message
  • 2MB per attachment
  • Attachment files cannot contain line breaks, quotes, or backslashes
  • Text-based files (for example, calendar invites) require converting the string: Buffer.from(text, 'utf-8')

맨 위로

My email isn't working

Below are some common errors that can occur and what they mean.

오류설명
Any status that's not 200Failure.
My email was accepted but not deliveredA successful call means the gateway accepted the message, but delivery happens out of your app or site. Check the spam mailbox of the recipient or log the messageId to trace delivery issues.
email ends in spam mailboxAttach a custom domain so mail comes from your own domain. Send both text and html versions of your email.
email send failedRead the error text. Common causes can be a missing field (to, subject, text and html or the from address is invalid.
email gateway unreachable: timed out after 30000msNo response within 30 seconds. If multiple attempts fail, contact a GoDaddy Guide for help.
email gateway unreachableMake sure the code runs on the server of your deployed app (not in the browser or your own computer).

맨 위로

상세 정보