月別アーカイブ: 2023年8月

const nodemailer = require(‘nodemailer’);

// GmailのSMTPサーバーを使用する場合
const transporter = nodemailer.createTransport({
service: ‘gmail’,
auth: {
user: ‘your-email@gmail.com’, // 送信元のGmailアドレス
pass: ‘your-password’ // Gmailアカウントのパスワード
}
});

const mailOptions = {
from: ‘your-email@gmail.com’, // 送信元のGmailアドレス
to: ‘recipient@example.com’, // 送信先のメールアドレス
subject: ‘テストメール’,
text: ‘これはテストメールです。’
};

transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log(‘メールが送信されました:’ + info.response);
}
});