Rate this page:

Integrating with the SMTP API

Integrating with SendGrid

To integrate with SendGrid's SMTP API:

  1. Create an API Key with at least "Mail" permissions.
  2. Set the server host in your email client or application to smtp.sendgrid.net. This setting is sometimes referred to as the external SMTP server or the SMTP relay.
  3. Set your username to the string apikey. This setting is the exact string "apikey" and not the API key itself.
  4. Set your password to the API key generated in step one.
  5. Set the port to 587 (or as specified below).

When submitting base64 encoded API key values, be sure you have not included any newline or whitespace characters by accident. This can happen when copying the encoded key from an environment that line wraps output. SMTP is a line-oriented protocol, and linefeed characters will prevent you from authenticating successfully.

SMTP ports

If you are unsure which port to use, a TLS connection on port 587 is typically recommended. To better understand the difference between ports 465 and 587, see the Twilio SendGrid blog post, "What's the Difference Between Ports 465 and 587".

Build SMTP email

Now that you've integrated, learn to build SMTP email.

Rate limits

  • You may send up to 5k messages per SMTP connection.
  • You may open up to 10k concurrent connections from a single server.

Additional resources

Rate this page:

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the SendGrid tag on Stack Overflow.

      
      
      

      Thank you for your feedback!

      We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

      Sending your feedback...
      🎉 Thank you for your feedback!
      Something went wrong. Please try again.

      Thanks for your feedback!

      Refer us and get $10 in 3 simple steps!

      Step 1

      Get link

      Get a free personal referral link here

      Step 2

      Give $10

      Your user signs up and upgrade using link

      Step 3

      Get $10

      1,250 free SMSes
      OR 1,000 free voice mins
      OR 12,000 chats
      OR more