mirror of
https://github.com/kou029w/_.git
synced 2025-02-03 23:58:44 +00:00
Compare commits
2 commits
e3843f842a
...
a115c1a929
Author | SHA1 | Date | |
---|---|---|---|
a115c1a929 | |||
8d6c754bbd |
7 changed files with 95 additions and 0 deletions
6
nodemailer/README.md
Normal file
6
nodemailer/README.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
```
|
||||||
|
docker compose up -d
|
||||||
|
# http://localhost:8025 にアクセスして確認
|
||||||
|
pnpm i
|
||||||
|
node index.mjs
|
||||||
|
```
|
19
nodemailer/compose.yml
Normal file
19
nodemailer/compose.yml
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
services:
|
||||||
|
# maildev:
|
||||||
|
# image: maildev/maildev
|
||||||
|
# ports:
|
||||||
|
# - "1080:1080" # Web UI
|
||||||
|
# - "1025:1025"
|
||||||
|
# environment:
|
||||||
|
# MAILDEV_INCOMING_USER: postmaster
|
||||||
|
# MAILDEV_INCOMING_PASS: password
|
||||||
|
mailpit:
|
||||||
|
image: axllent/mailpit
|
||||||
|
ports:
|
||||||
|
- "8025:8025" # Web UI
|
||||||
|
- "1025:1025"
|
||||||
|
environment:
|
||||||
|
MP_SMTP_AUTH_FILE: /etc/mailpit/auth
|
||||||
|
MP_SMTP_AUTH_ALLOW_INSECURE: "true"
|
||||||
|
volumes:
|
||||||
|
- ./etc/mailpit:/etc/mailpit:ro
|
1
nodemailer/etc/mailpit/auth
Normal file
1
nodemailer/etc/mailpit/auth
Normal file
|
@ -0,0 +1 @@
|
||||||
|
postmaster:password
|
20
nodemailer/index.mjs
Normal file
20
nodemailer/index.mjs
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
import nodemailer from "nodemailer";
|
||||||
|
|
||||||
|
const transporter = nodemailer.createTransport({
|
||||||
|
host: "localhost",
|
||||||
|
port: 1025,
|
||||||
|
secure: false,
|
||||||
|
auth: {
|
||||||
|
user: "postmaster",
|
||||||
|
pass: "password",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const info = await transporter.sendMail({
|
||||||
|
from: "foo <foo@example.com>",
|
||||||
|
to: "bar <bar@example.com>",
|
||||||
|
subject: "Hello world!",
|
||||||
|
html: "<marquee>Hello world.</marquee>",
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(info.messageId);
|
15
nodemailer/package.json
Normal file
15
nodemailer/package.json
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"name": "nodemailer",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "Kohei Watanabe <kou029w@gmail.com>",
|
||||||
|
"license": "MIT",
|
||||||
|
"devDependencies": {
|
||||||
|
"nodemailer": "^6.9.4"
|
||||||
|
}
|
||||||
|
}
|
13
nodemailer/pnpm-lock.yaml
generated
Normal file
13
nodemailer/pnpm-lock.yaml
generated
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
lockfileVersion: '6.0'
|
||||||
|
|
||||||
|
devDependencies:
|
||||||
|
nodemailer:
|
||||||
|
specifier: ^6.9.4
|
||||||
|
version: 6.9.4
|
||||||
|
|
||||||
|
packages:
|
||||||
|
|
||||||
|
/nodemailer@6.9.4:
|
||||||
|
resolution: {integrity: sha512-CXjQvrQZV4+6X5wP6ZIgdehJamI63MFoYFGGPtHudWym9qaEHDNdPzaj5bfMCvxG1vhAileSWW90q7nL0N36mA==}
|
||||||
|
engines: {node: '>=6.0.0'}
|
||||||
|
dev: true
|
21
nodemailer/sendgrid.mjs
Normal file
21
nodemailer/sendgrid.mjs
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
import nodemailer from "nodemailer";
|
||||||
|
|
||||||
|
// see https://support.sendgrid.kke.co.jp/hc/ja/articles/204187885-SMTP%E3%81%AE%E6%8E%A5%E7%B6%9A%E6%83%85%E5%A0%B1%E3%82%92%E6%95%99%E3%81%88%E3%81%A6%E3%81%8F%E3%81%A0%E3%81%95%E3%81%84-
|
||||||
|
const transporter = nodemailer.createTransport({
|
||||||
|
host: "smtp.sendgrid.net",
|
||||||
|
port: 465,
|
||||||
|
secure: true,
|
||||||
|
auth: {
|
||||||
|
user: "apikey",
|
||||||
|
pass: "SG.****", // https://app.sendgrid.com/settings/api_keys > Create API Key > Mail Send > Custom Access > Mail Send
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const info = await transporter.sendMail({
|
||||||
|
from: "foo@example.org",
|
||||||
|
to: "bar@example.org",
|
||||||
|
subject: "Hello world!",
|
||||||
|
html: "<marquee>Hello world.</marquee>",
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(info.messageId);
|
Loading…
Add table
Reference in a new issue