Instalacja modułu
# npm install nodemailer
Konfiguracja: https://nodemailer.com/smtp/
const nodemailer = require('nodemailer') const mailTransport = nodemailer.createTransport({ pool: true, // wyślij dopiero gdy dostępne połączenie - def. false host: "smtp.example.com", // def. localhost port: 465, // default 465 secure: true, // TLS auth: { user: credentials.sendgrid.user, pass: credentials.sendgrid.password, }, authMethod: "PLAIN" // rodzaj autoryzacji def. PLAIN })
Wysyłka poczty
try {
const result = await mailTransport.sendMail({
from: '"Meadowlark Travel" <info@meadowlarktravel.com>',
to: 'joecustomer@gmail.com',
subject: 'Your Meadowlark Travel Tour',
text: 'Thank you for booking your trip with Meadowlark Travel. ' +
'We look forward to your visit!',
})
console.log('mail sent successfully: ', result)
} catch(err) {
console.log('could not send mail: ' + err.message)
}
Generator obrazów o różnych rozmiarach: https://placehold.it/100×100