
const nodemailer = require('nodemailer');
const transport = nodemailer.createTransport({
    host:process.env.SMTP_HOST || 'localhost',
    port:process.env.SMTP_PORT ||25,
    secure:Boolean(process.env.SMTP_SECURE) || false,

    auth:{
        user:process.env.SMTP_USER||'',
        pass:process.env.SMTP_PASS||''
    }

})

function viaNodemailer(mailOptions){
    return new Promise(async(resolve, reject) =>{
           await  transport.sendMail(mailOptions).then(e=>{
                resolve()
            }).catch(err=>{
                reject(err)
            })
    })

}


async function mail(mailOtions,{
    driver='nodemailer'
}){


if(driver=='nodemailer') return await viaNodemailer(mailOtions)


}





export {
    mail
}