const nodemailer = require('nodemailer');
// Örnek e-posta ayarları.
const transporter = nodemailer.createTransport({
service: 'Gmail',
auth: {
user: 'example@gmail.com',
pass: 'password'.
}
});
// Gönderen e-posta adresini dinamik olarak belirleme.
const mailOptions = {
from: req.body.mail || 'example@gmail.com', // Gönderenin e-posta adresi, eğer req.body.mail tanımlıysa kullanılır, değilse varsayılan olarak 'example@gmail.com' kullanılır.
to: "mertduyar16@gmail.com",
subject: `Staj Başvuru Formu`,
text: `
İsim: ${req.body.isim}
Mail: ${req.body.mail}
Telefon: ${req.body.telefon}
Staj Konusu: ${req.body.stajKonusu}
Staj Süresi: ${req.body.stajSuresi}
Staj Dönemi: ${req.body.stajDönemi}
CV Dosyası: ${req.body.cvDosyasi}
Staj Dönemi ile ilgili Görüş/Mesaj: ${req.body.comment}
`,
};
// E-postayı gönderme.
transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log('Email gönderildi: ' + info.response);
}
});