mailersend / mailersend-nodejs

The official MailerSend Node.js SDK
https://developers.mailersend.com
MIT License
136 stars 17 forks source link

Send at feature does not work and send email immediately #50

Closed Bluedot-Dev closed 2 years ago

Bluedot-Dev commented 2 years ago

Hello,

I am trying to send a delayed email to our customers. However, the email is delivered immediately. My code


const sendAt: number = (Math.floor(+new Date() / 1000) + 2 * 24 * 60 * 60)

 const recipients = [
        new Recipient(to, name)
    ];
    if (values == null){
        values = {name}
    }

    const personalization = [
        {
            email: to,
            data: values,
        }
    ];

    const templateId = templates[templateName];

    const emailParams = new EmailParams()
        .setFrom("info@thebluedot.co")
        .setFromName("Bluedot")
        .setRecipients(recipients)
        .setReplyTo("info@thebluedot.co")
        .setTemplateId(templateId)
        .setSubject(subject)
        .setPersonalization(personalization)

    if (sendAt != null){
        emailParams.setSendAt(sendAt);
    }

    console.log(emailParams);

    return await mailerSend.send(emailParams);