---
"@context": https://schema.org
"@type": TechArticle
"@id": https://www.twilio.com/docs/sendgrid/for-developers/sending-email/sendmail#article
headline: Sendmail
description: Resolve Sendmail's authentication requests with libsasl for SendGrid servers. Implement cyrus-sasl-plain upon approval, and set Smart Host in sendmail.mc.
url: https://www.twilio.com/docs/sendgrid/for-developers/sending-email/sendmail
inLanguage: en
dateModified: 2026-07-17T03:36:59.000Z
author:
  "@type": Organization
  name: Twilio Developer Education Team
publisher:
  "@type": Organization
  name: Twilio
---

# Sendmail

To route Sendmail through SendGrid's SMTP service, configure SASL authentication and set SendGrid as the Smart Host. The following steps show how to configure the credentials, define the Smart Host, and restart Sendmail.

> \[!CAUTION]
>
> Sendmail requires libsasl in order to properly send authentication requests to SendGrid servers. The saslauthd server daemon is not required unless you plan to receive authentication requests to the same server.

Set the authorization credentials in **/etc/mail/access**

> \[!CAUTION]
>
> We have had reports that some customers have needed to install `cyrus-sasl-plain` in order to avoid authentication issues as well. We have not validated this requirement, so please make sure your system administrators, Ops, and/or InfoSec people approve this change before you make it!

```bash
AuthInfo:smtp.sendgrid.net "U:apikey" "P:yourAPIKey" "M:PLAIN"
```

Define the Smart Host in **/etc/mail/sendmail.mc** You should add these lines just after the commented `\#dnl define('SMART_HOST', 'smtp.your.provider')dnl` line in the file

```bash
define(`SMART_HOST', `smtp.sendgrid.net')dnl
FEATURE(`access_db')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl
define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl
```

Update `sendmail.cf` and `access.db` files

(You will need to run these commands as 'su' or 'root')

```bash
cd /etc/mail
m4 sendmail.mc >sendmail.cf
makemap hash access.db < access
```

On older distros, you can run restart sendmail like so:

```bash
/etc/init.d/sendmail restart
```

If, however, you're using a newer version, do the following to restart:

```bash
service sendmail restart
```
