2FA NOW REQUIRED: Twilio is requiring two-factor authentication (2FA) as an additional layer of protection for all paying Twilio customers. For more details, see our 2FA Setup Guide.

Troubleshooting Twilio SendGrid email delivery delays and latency

Experiencing delays? Check our Status Page for the current state of all Twilio SendGrid Services.

As you send email, you may encounter scenarios where mail seems to take more time than it should to get to its final destination. Mail delays can manifest in a number of ways, so we've collected a list of tips to help you try to track them down. This guide covers the following topics for diagnosing and resolving your issues:

Please start at the top, and walk through each of the troubleshooting steps as you work your way down the page.

Verify you’re using an official Twilio SendGrid library

If you are integrated with Twilio SendGrid using code, we highly recommend using the official Twilio SendGrid libraries. You can find links for all of our official SDKs and getting started tutorials at API Libraries (SendGrid docs).

Use the Twilio SendGrid SMTPAPI

You can use our SMTPAPI to greatly increase your message throughput. As with SMTP, 100 messages can be sent with each connection, but there can be 1000 'TO:'  recipients for each message using the x-smtpapi header. You can use this option through SMTP sending as well as the Web API v3.

Try opening additional connections

Lastly, you can try to open additional connections from your end. Generally, we recommend a maximum of 10 concurrent connections. However, please note that Twilio SendGrid can handle as much mail as you can throw at us.

One important thing to remember is make certain that the maximum amount of mail is passed before terminating each connection. We recommend using caution when incrementing your number of active connections.

Check your network latency

More often that not, one of the 3 prior suggestions above will resolve a latency problem. However, some latency issues are simply due to the quality of your connection or traffic shaping. It's possibile that your network problem lies with either you or your ISPs configuration. Below are a number of methods that will help you determine where a latency issue really is.

Ping: You should use a ping test to help determine response time and TTL (time to live) in milliseconds. To run a ping test, open a terminal or command prompt window, and then type the following command:

ping smtp.sendgrid.net

Tip: Appending the parameter -t to the end of your ping command on Windows machines will run a continuous ping test. Simultanteously press the control and C keys to end your test.

Anything exceeding 150.000ms should be the first indication that something may be amiss regarding your network connection.

Traceroute: A traceroute test will follow the the path from your computer to SendGrid's servers, displaying each connection and the latency. This allows you to see if there is any latency in your connection to SendGrid. To run a traceroute test, open a terminal window, and then type the following command:

traceroute smtp.sendgrid.net

Tip: Windows users, type tracert smtp.sendgrid.net

As with the ping method, keep an eye out for any times over 150.000ms. You'll also want to pay close attention to notice if there are any major increases from one hop to the next. This could indicate the inherent latency from when the packet leaves a server in France en route to a server in Canada. Another flag to watch out for are any of the increases early in the transit, as this could mean the latency lies within your local network, or at a certain ISP.

Additionally, please keep in mind that many modern network nodes will de-prioritize ICMP packets (which traceroute sends), so timeouts at certain hops may not necessarily be indicative of a faulty connection. That said, a traceroute can still go along way in helping isolate where a network issue exists.

Review email headers

Google provides a free header analyzer tool that you can use to analyze the headers of an email, and find out how long an email spent in a particular location. For more information, see How do I check the headers/raw source of an email (SendGrid.com).

Make sure to only analyze the received headers, which is everything above the first content boundary. The results provided should show the exact journey a message takes from one Mail Transfer Agent to the next, and how long it spent at each one.

Packet capture and analysis

In cases where ping and traceroute fail to uncover any obvious lag, a TCP dump or packet capture (PCAP) can tell us a lot. This can be helpful for analyzing traffic, filtering TCP streams, and more. When troubleshooting latency issues, the Twilio SendGrid support team may ask you for a PCAP to give us better visibility.

If you're not familiar with this process, we recommend using this helpful guide for collecting packet captures with Wireshark: How to Use Wireshark to Capture, Filter and Inspect Packets (HowtoGeek.com).

Notice: Make sure that the PCAP covers your attempt to send a single message to SMTP.sendgrid.net.

Have more questions? Submit a request