UNPKG

@mathrunet/masamune

Version:

Manages packages for the server portion (NodeJS) of the Masamune framework.

64 lines 2.61 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.send = send; const nodemailer_1 = require("nodemailer"); /** * Send email via Gmail. * * Gmailでメールを送信します。 * * @param {string} process.env.MAIL_GMAIL_ID * Gmail user ID. Follow the steps below to obtain a Gmail user ID. * 1. Press your icon in the upper right corner of the Google top screen and open "Manage Google Account". * 2. open "Security" on the left side of the screen and open "App Password * GmailのユーザーID。下記の手順で取得します。 * 1. Googleのトップ画面の画面右上の自分のアイコンを押下し、「Google アカウントを管理」を開く * 2. 画面左の「セキュリティ」を開き、「アプリ パスワード」を開く * * @param {string} process.env.MAIL_GMAIL_PASSWORD * Gmail user password. Enter the password obtained in the above procedure. * Gmailのユーザーパスワード。上記の手順で取得したパスワードを入力します。 * * @param {string} from * Sender's email address. * 送信元メールアドレス。 * * @param {string} to * Email address to be sent to. * 送信先メールアドレス。 * * @param {string} title * Email Title. * メールタイトル。 * * @param {string} content * Email content. * メール本文。 */ function send(_a) { return __awaiter(this, arguments, void 0, function* ({ from, to, title, content, }) { const mailTransport = (0, nodemailer_1.createTransport)({ service: "gmail", auth: { user: process.env.MAIL_GMAIL_ID, pass: process.env.MAIL_GMAIL_PASSWORD, }, }); yield mailTransport.sendMail({ from: from, to: to, subject: title, text: content, }); }); } //# sourceMappingURL=gmail.js.map