Sendgrid-nodejs: Whatever I do, emails are sent immediately and not respecting the `sendAt`

Created on 9 Feb 2020  路  8Comments  路  Source: sendgrid/sendgrid-nodejs

I am trying to create a scheduled email. I changed my timezone to America/New_York, then sends unix (seconds) as the setAt value. (I have also tried send_at per the documentation).

None of is respected at all, my emails are being sent the moment I request the API.

Code Snippet

      to: [
        {
          name: "John",
          email: "[email protected]"
        }
      ],
      from: {
        email: "[email protected]"
      },
      subject: "test",
      template_id: "",
      dynamic_template_data: {
        example: `<a href="#">example</a>`
      },
      bcc: [
        {
          email: "...."
        }
      ],
      sendAt: 1581183600

Technical details:

  • sendgrid-nodejs version: ^6.4.0
  • node version: v12.13.1
waiting for feedback question

All 8 comments

Just tried this and worked as expected. sendAt is the correct name for this library. Note that the timestamp in your example was several hours before this issue was filed so maybe it's not being generated correctly. Quick way to test the timestamp by entering it here: https://www.epochconverter.com/

I tested the timestamp and it was correct, but still the email was being sent immediately.

Could you post the message payload here using a future timestamp that's sending immediately?

console.log(JSON.stringify(Mail.create(msg), null, 2));

Nothing is being logged using what you sent, but here for example the unix I send 1583496600

I think i found my issue so far, but I need to understand how your backend works guys. If I send 1583496600 is it converted to UTC or to the timezone from my settings?

I believe the value is expected to be seconds since unix epoch UTC. The value 1583496600 is currently over 3 hours in the past.

Ok so it's considered UTC in the end, the documentation misrepresented this, because I read that I should chose the timezone from my account settings or set the timezone using the API, then just send seconds, but instead I have to include my timezone also in the unix, this makes the API part of setting the timezone, useless in the end.

The timezone setting does not impact the send_at value.

From here: https://sendgrid.com/docs/API_Reference/Web_API/timezone.html

A user鈥檚 timezone affects the displayed dates on all Suppression Lists and Statistics.

I think it also applies to scheduled sends from the console where you're using a date picker.

Do you have a link to the docs where it's misrepresented? I've not been able to find anything.

Generally speaking, when providing a unix timestamp it is time since UTC epoch.

I see your comment here: https://github.com/sendgrid/sendgrid-ruby/issues/377#issuecomment-583781414

I'll redirect to this post.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

polkhovsky picture polkhovsky  路  3Comments

amlcodes picture amlcodes  路  4Comments

Chrischuck picture Chrischuck  路  3Comments

agostonbonomi picture agostonbonomi  路  3Comments

umarhussain15 picture umarhussain15  路  3Comments