SMTP Service – Breavo

๐Ÿ‘‰๐Ÿป SMTP(Simple Mail Transfer Protocol) ๋ฉ”์ผ ๋ฐœ์†ก์— ์„œ๋น„์Šค ๋Œ€ํ•ด์„œ ์†Œ๊ฐœํ•˜๊ณ ์ž ํ•ฉ๋‹ˆ๋‹ค.
I would like to introduce the SMTP (Simple Mail Transfer Protocol) email sending service.

๐Ÿ‘‰๐Ÿป ์•ฑ์œผ๋กœ ํšŒ์›๊ฐ€์ž… ๊ธฐ๋Šฅ์„ ๋งŒ๋“ค๊ฑฐ๋‚˜ ๋น„์ง€๋‹ˆ์Šค๋ฅผ ์œ„ํ•ด์„œ ๊ด‘๊ณ ๋‚˜ ์†Œ์‹์„ ์ „๋‹ฌํ• ๊ฒฝ์šฐ ์ด๋ฉ”์ผ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.
An email address is required when implementing a sign-up feature in an app or when delivering advertisements or news for business purposes.

๐Ÿ‘‰๐Ÿป ๊ทธ๋ฆฌ๊ณ  ์ง€๊ธˆ ๋งŒ๋“ค๊ณ  ํŒ”๋กœ์šฐ ๊ธฐ๋Šฅ์„ ๋งŒ๋“ค๊ณ  ์žˆ๋Š” nextjs sns์„œ๋น„์Šค์—๋„ ๋ฉ”์ผ ์„œ๋น„์Šค๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.
Also, the Next.js-based social networking service I am currently buildingโ€”which includes a follow featureโ€”requires an email service.

๐Ÿ‘‰๐Ÿป ์ด๋Ÿด ๊ฒฝ์šฐ ๋ฉ”์ผ์„ ๋ฐœ์†กํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” SMTP ์„œ๋ฒ„๊ฐ€ ํ•„์š”ํ•˜๊ฒŒ๋ฉ๋‹ˆ๋‹ค.
In this case, an SMTP server is required to send emails.

๐Ÿ‘‰๐Ÿป SMTP์„œ๋ฒ„๋Š” ๊ฐ„๋‹จํžˆ ์ง์ ‘ ๊ตฌ์ถ•ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
You can easily set up an SMTP server yourself.

๐Ÿ‘‰๐Ÿป ํ•˜์ง€๋งŒ ์š”์ฆ˜ ์ŠคํŒธ๋ฉ”์ผ์ด ๋„ˆ๋ฌด ๋งŽ์•„์„œ ์›น ๋ฉ”์ผ์„œ๋น„์Šค๋ฅผ ์ œ๊ณตํ•˜๋Š” ์—…์ฒด์—์„œ ์ŠคํŒธ๋ฉ”์ผ์— ๋Œ€ํ•œ ์ •์ฑ…์ด ๋งค์šฐ ๊ฐ•ํ•˜๊ฒŒ ์ ์šฉ๋˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.
However, due to the sheer volume of spam emails these days, webmail service providers are enforcing very strict policies regarding spam.

๐Ÿ‘‰๐Ÿป ๋Œ€๋ถ€๋ถ„์˜ ๋ฉ”์ผ์„œ๋น„์Šค๋Š” ํฌํ„ธ ์‚ฌ์ดํŠธ ๋ฉ”์ผ์„ ๋งŽ์ด ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
Most people use email services provided by portal sites.

๐Ÿ‘‰๐Ÿป ์ •ํ™•ํ•˜๊ฒŒ ํฌํ„ธ ์‚ฌ์ดํŠธ ๋ฉ”์ผํ•จ์— ๋‚ด ๋ฉ”์ผ์ด ๋„์ฐฉํ•˜๊ฒŒ ํ•˜๊ธฐ ์œ„ํ•ด์„œ ์„ค์ •์— ๋งŽ์€ ๋ถˆํŽธํ•จ์ด ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ์™ธ๋ถ€์—…์ฒด์˜ ๋ฉ”์ผ๋ฐœ์†ก ์„œ๋น„์Šค๋ฅผ ๋งŽ์ด ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
Configuring settings to ensure emails reliably reach the inboxes of major portal sites can be quite cumbersome, which is why many people use third-party email delivery services.

๐Ÿ‘‰๐Ÿป ๋งŽ์€ ๋Œ€ํ‘œ์ ์œผ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๊ณณ์ด Breavo.com์ด๋ž€ ๊ณณ์ด ์žˆ์Šต๋‹ˆ๋‹ค.
One prominent example of a service you can use is Breavo.com.

๐Ÿ‘‰๐Ÿป ๋ฌด๋ฃŒ ํ”Œ๋žœ์œผ๋กœ ๊ฐ€์ž…ํ•˜๋ฉด ํ•˜๋ฃจ์— 300ํ†ต์˜ ๋ฉ”์ผ์„ ๋ฌด๋ฃŒ๋กœ ์ „์†กํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
If you sign up for the free plan, you can send 300 emails per day for free.

๐Ÿ‘‰๐Ÿป nodejs์„ ์ด์šฉํ•ด์„œ ์ œ๊ฐ€ ์‚ฌ์šฉํ•˜๋Š” ํฌํ„ธ ์‚ฌ์ดํŠธ์˜ ๋ฉ”์ผํ•จ์œผ๋กœ ๋ฉ”์ผ์„ ๋ณด๋‚ด๋ด…๋‹ˆ๋‹ค.
I am using Node.js to send an email to the inbox of the portal site I use.


๐Ÿ“ Brevo.com ํšŒ์›๊ฐ€์ž… ๋ฐ ์„ค์ •
Brevo.com Sign-up and Setup

โœ”๏ธ ์ €๋Š” ๊ฐ„๋‹จํžˆ ์†Œ์…œ ๋กœ๊ทธ์ธ์„ ์ด์šฉํ•ด์„œ ๊ตฌ๊ธ€๊ณ„์ •์œผ๋กœ ๊ฐ€์ž…ํ–ˆ์Šต๋‹ˆ๋‹ค.
I simply signed up using my Google account via social login.

โœ”๏ธ ์•„๋ž˜๋Š” Breavo.com์—์„œ smtp key๋ฅผ ๋ฐ›๋Š” ๊ณผ์ •์ž…๋‹ˆ๋‹ค.

1) ๋ธŒ๋ผ์šฐ์ € ํ™”๋ฉด ์•„๋ž˜๋กœ ๋‚ด๋ฆฌ๋ฉด Free Plan ์„ ์„ ํƒ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
Scroll down the browser screen to select the Free Plan.

Free Plan

2) ๋ชจ๋งˆ์ผ ํฐ ์ธ์ฆ / Mobile phone verification

verify mobile phone
verify mobile phone

3)SMTP ํ‚ค ์ƒ์„ฑ / Generate SMTP Key

3-1) ์šฐ์ธก์˜ ํ”„๋กœํ•„ ๋ฉ”๋‰ด๋ฅผ ์„ ํƒํ•˜๋ฉด ์™ผ์ชฝ์— SMTP & API ๋ฉ”๋‰ด๋ฅผ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
If you select the profile menu on the right, you can see the SMTP & API menu on the left.

SMTP Key
smtp key generate

๐Ÿ“ Nodejs ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ
Create a Node.js project

npm init -y

๐Ÿ“ nodemailer ๋ชจ๋“ˆ ์„ค์น˜
Install the nodemailer module.

npm install nodemailer

๐Ÿ“ package.json ์ฝ”๋“œ ์ˆ˜์ •
Modify package.json code

โœ”๏ธ import๊ตฌ๋ฌธ์„ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ type: “commonjs”๋ฅผ type:”module”๋กœ ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค.
To use the import statement, change type: "commonjs" to type: "module".

{
  "name": "breavo-smtp",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "type": "module",
  "dependencies": {
    "nodemailer": "^9.0.5"
  }
}

๐Ÿ“ send.js ์ฝ”๋“œ์ž‘์„ฑ / Writing the send.js code

import nodemailer from "nodemailer";

const transporter = nodemailer.createTransport({
  host: "smtp.brevo.com",
  port: 587,
  secure: false, // 587 ํฌํŠธ๋Š” STARTTLS ๋ฐฉ์‹์„ ์“ฐ๋ฏ€๋กœ false๋กœ ๋‘ก๋‹ˆ๋‹ค. / The 587 port uses STARTTLS, so set it to false.
  auth: {
    user: "๋ณธ์ธ์˜ Brevo ๊ฐ€์ž… ์ด๋ฉ”์ผ ์ฃผ์†Œ / Your Brevo account email address", 
    pass: "64์ž๋ฆฌ ๋น„๋ฐ€ํ‚ค / Your 64-character secret key" 
  }
});

const mailOptions = {
   // ๋ฐœ์‹ ์ž์™€ ID๋ฅผ ์ผ์น˜์‹œ์ผœ ์ค๋‹ˆ๋‹ค. / Make sure the sender matches the ID.
  from: "๋ณธ์ธ์˜ Brevo ๊ฐ€์ž… ์ด๋ฉ”์ผ ์ฃผ์†Œ / Your Brevo account email address", 
  to: "ํ™•์ธํ•ด ๋ณผ ๋ณธ์ธ์˜ ๋‹ค๋ฅธ ๊ฐœ์ธ ์ด๋ฉ”์ผ (์ง€๋ฉ”์ผ, ๋„ค์ด๋ฒ„,๋‹ค์Œ ๋“ฑ) / The other personal email you want to check (e.g., Gmail, Naver,Daum etc.)",
  subject: "Brevo SMTP ์ดˆ๊ฐ„๋‹จ ์—ฐ๋™ ํ…Œ์ŠคํŠธ / Simple Brevo SMTP Integration Test",
  text: "๋ฉ”์ผ ๋ฐœ์†ก ์„ฑ๊ณตํ–ˆ์Šต๋‹ˆ๋‹ค! / Email sent successfully!"
};

async function sendTest() {
  try {
    const info = await transporter.sendMail(mailOptions);
    console.log("โœ… ๋ฐœ์†ก ์„ฑ๊ณต! ๋ฉ”์‹œ์ง€ / Success! Message ID:", info.messageId);
  } catch (error) {
    console.error("โŒ ๋ฐœ์†ก ์‹คํŒจ ์—๋Ÿฌ ๋‚ด์šฉ / Error occurred while sending email:", error);
  }
}

sendTest();

โœ”๏ธ ๋ฉ”์ผ ๋ฐœ์†ก์™„๋ฃŒ / Email sent successfully.

node send.js
breavo-smtp % node send.js
โœ… ๋ฐœ์†ก ์„ฑ๊ณต! ๋ฉ”์‹œ์ง€ / Success! Message ID: <fd1f1954-63e5-6502-1252-14a0ae09758a@gmail.com>

1)ํ…Œ์ŠคํŠธ ๊ฒฐ๊ณผ ๋„ค์ด๋ฒ„,์ง€๋ฉ”์ผ์€ ์ •์ƒ์ ์œผ๋กœ๋ฉ”์ผ ๋„์ฐฉํ™•์ธํ–ˆ๊ณ  ๋‹ค์Œ์€ ๋ฉ”์ผ์ด ๋„์ฐฉํ•˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค.
Test results showed that emails arrived normally for Naver and Gmail, but the email did not arrive for Daum.

2) ๋‹ค์Œ์€ ์ž์ฒด ๋ฉ”์ผ ์ •์ฑ…์œผ๋กœ ์ธํ•ด ๋ฉ”์ผ์ด ๋„์ฐฉํ•˜์ง€ ์•Š์€ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.
It appears that the email did not arrive due to internal email policies.

gmail
naver

์š”ํ•œ๋ณต์Œ 8์žฅ 32์ ˆ / John 8:32

“๊ทธ๋ฆฌ๊ณ  ๋„ˆํฌ๋Š” ์ง„๋ฆฌ๋ฅผ ์•Œ๊ฒŒ ๋  ๊ฒƒ์ด๋ฉฐ, ์ง„๋ฆฌ๊ฐ€ ๋„ˆํฌ๋ฅผ ์ž์œ ๋กญ๊ฒŒ ํ•  ๊ฒƒ์ด๋‹ค.”

“Then you will know the truth ,and the truth will set you free”

Leave a Reply