# Digitalocean with Sendgrid SMTP Relay

**URL:** <https://discourse.mailinabox.email/t/digitalocean-with-sendgrid-smtp-relay/10204>\
**Category:** uncategorized\
**Created:** [March 6, 2023, 6:09pm UTC](https://discourse.mailinabox.email/t/digitalocean-with-sendgrid-smtp-relay/10204 "2023-03-06T18:09:19Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![AskinSavascisi](https://discourse.mailinabox.email/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@AskinSavascisi](https://discourse.mailinabox.email/u/AskinSavascisi)\
**Post date:** [March 6, 2023, 6:09pm UTC](https://discourse.mailinabox.email/t/digitalocean-with-sendgrid-smtp-relay/10204/1 "2023-03-06T18:09:20Z")

</div>

Hi,

I’m fairly new to the vps world, i’ve used shared hosting for over 6 years and because our Laravel app got bigger and we needed queu workers, we made the switch to digitalocean droplet with Laravel Forge.

Everything’s running smootly except our emails… i dont want to use google mail services or anyother because we have a few mails on our team and that’s why i made another droplet for Mail-in-a-box server.

i’ve found the following link and made the same changes:

> **[Integrate SendGrid with Postfix - SendGrid Documentation | SendGrid](https://docs.sendgrid.com/for-developers/sending-email/postfix)**
>
> Setup SendGrid as a Postfix relay host for better deliverability and advanced statistics on your email.

if i run the following command:

echo “my testing messages lala” | mail -s “test emaillolo” -r “John[john@doe.be](mailto:john@doe.be)” mary@doe.be

i’m getting the email, which is a good sign, means that ive setup it right.

however emails sent from webmail or mail client Spark on my android phone don’t get delivered…

Am I doing something wrong?

Thanks in advance.

AskinSavascisi

---

<div class="post-metadata">

**Author:** ![matidau](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/matidau/32/2838_2.png) [@matidau](https://discourse.mailinabox.email/u/matidau)\
**Post date:** [March 6, 2023, 7:09pm UTC](https://discourse.mailinabox.email/t/digitalocean-with-sendgrid-smtp-relay/10204/2 "2023-03-06T19:09:23Z")

</div>

Hiya,

Personally don’t use a relay but see this discussion:

> [@Sending mail via Sendgrid Web API](https://discourse.mailinabox.email/t/sending-mail-via-sendgrid-web-api/5028):
>
> Hi guys, I’m trying to test Sendgrid to relay our emails. I’ve already authenticated our domain with them. The next step is integration via Web API or SMTP Relay. They recommend Web API so I’m choosing that. Then I arrive to a page asking me to choose the Language I want to use (Node.js, Python, PHP, Java, Ruby, Go, C#, cURL). I guess I should be choosing cURL (because to install MIAB we use a command that starts with curl…). Then I get to this page: If I connect…

There’s a link to a guide that is recommended in it:

[https://www.linode.com/docs/email/postfix/postfix-smtp-debian7/](https://www.linode.com/docs/email/postfix/postfix-smtp-debian7/)

If you are having problems would recommend jumping on the slack chat.

Cheers,  
Mat

---

<div class="post-metadata">

**Author:** ![AskinSavascisi](https://discourse.mailinabox.email/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@AskinSavascisi](https://discourse.mailinabox.email/u/AskinSavascisi)\
**Post date:** [March 7, 2023, 10:45am UTC](https://discourse.mailinabox.email/t/digitalocean-with-sendgrid-smtp-relay/10204/3 "2023-03-07T10:45:04Z")

</div>

Hi,

For those who struggled to integrate sendgrid with mail in a box, you need to edit the contents of main.cf located in /etc/postfix/ like mentioned in the following post:

> **[Integrate SendGrid with Postfix - SendGrid Documentation | SendGrid](https://docs.sendgrid.com/for-developers/sending-email/postfix)**
>
> Setup SendGrid as a Postfix relay host for better deliverability and advanced statistics on your email.

However i thought that i needed to change the contents of main.cf file to the given details on the tutorial, which is not the case,

you just need to do the following:

1. change following line in main.cf:  
relayhost = → relayhost = [[smtp.sendgrid.net](http://smtp.sendgrid.net)]:587

and append/add the following text block under relayhost

```auto
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_tls_security_level = encrypt
header_size_limit = 4096000

```

you still need to follow the other steps and it’ll work out.

Kind regards,

AskinSavascisi

---

<div class="post-metadata">

**Author:** ![mats](https://discourse.mailinabox.email/letter_avatar_proxy/v4/letter/m/b4bc9f/32.png) [@mats](https://discourse.mailinabox.email/u/mats)\
**Post date:** [August 30, 2023, 9:24pm UTC](https://discourse.mailinabox.email/t/digitalocean-with-sendgrid-smtp-relay/10204/4 "2023-08-30T21:24:24Z")

</div>

Thanks AskinSavascisi,

I struggled a bit with gething this to work with mailgun.

But after adding your options to main.cf it worked.

Thank you!

---

<div class="post-metadata">

**Author:** ![sky1dev](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/sky1dev/32/2668_2.png) [@sky1dev](https://discourse.mailinabox.email/u/sky1dev)\
**Post date:** [December 15, 2023, 8:00pm UTC](https://discourse.mailinabox.email/t/digitalocean-with-sendgrid-smtp-relay/10204/5 "2023-12-15T20:00:46Z")

</div>

First I just wanted to thank you and the community for these instructions on setting up Sendgrid as an SMTP relay service. It works great to get around the insufferable IP reputation issue (due to the UCEPROTECTL3 blacklist) that comes with being a Digital Ocean customer.

These instructions worked perfectly. But like others will surely find out, if they haven’t already, using Sendgrid comes with its own set of issues. Their IP’s get blacklisted too and since you’ll, in most cases, be using a shared IP, your reputations will get slammed with the rest of the spammers - AGAIN! So, if you’re like me, you’ll want to try Mailgun. The issue with Mailgun is they force you to authenticate each domain name you use on your MIAB install. In that case, here are the steps I followed to get that up and running. If you’re only running one domain name on your MIAB, then you can probably follow the same steps for Sendgrid except for the one line that should look like this instead:

```auto
smtp_sasl_password_maps = static:postmaster@yourdomain.com:yourpassword

```

The username and password is created in Mailgun.

But when you have multiple domains on one install, you’ll need to follow the steps outlined here:

[https://beesbuzz.biz/blog/9902-Setting-up-Postfix-Mailgun-for-multiple-outgoing-domains](https://beesbuzz.biz/blog/9902-Setting-up-Postfix-Mailgun-for-multiple-outgoing-domains)  
Same page archived here: [https://archive.is/UNohx](https://archive.is/UNohx)

So far, so good…

Until Mailgun gets blacklisted.

Good luck!

---

<div class="post-metadata">

**Author:** ![AskinSavascisi](https://discourse.mailinabox.email/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@AskinSavascisi](https://discourse.mailinabox.email/u/AskinSavascisi)\
**Post date:** [December 17, 2023, 10:08am UTC](https://discourse.mailinabox.email/t/digitalocean-with-sendgrid-smtp-relay/10204/6 "2023-12-17T10:08:40Z")

</div>

Hi,

Thank you for your valuable feedback.

İ’ve switched over from DO to hetzner, because of the price and ip listing. İm using entirely my own email server now without relay hosts. And ip’s are not blacklisted. İm allready using it for a few months.

King regards,

Askin

---

<div class="post-metadata">

**Author:** ![sky1dev](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/sky1dev/32/2668_2.png) [@sky1dev](https://discourse.mailinabox.email/u/sky1dev)\
**Post date:** [July 20, 2025, 6:10pm UTC](https://discourse.mailinabox.email/t/digitalocean-with-sendgrid-smtp-relay/10204/7 "2025-07-20T18:10:47Z")

</div>

Hetzner has most, if not all, of its IP’s automatically blocked by ProofPoint. Check your IPs here: [https://www.proofpoint.com/us/ipcheck](https://www.proofpoint.com/us/ipcheck)

---

<div class="post-metadata">

**Author:** ![terrytokyo](https://discourse.mailinabox.email/letter_avatar_proxy/v4/letter/t/8c91f0/32.png) [@terrytokyo](https://discourse.mailinabox.email/u/terrytokyo)\
**Post date:** [July 20, 2025, 11:26pm UTC](https://discourse.mailinabox.email/t/digitalocean-with-sendgrid-smtp-relay/10204/8 "2025-07-20T23:26:55Z")

</div>

My 10 cents worth for what it is worth.

1. Spin up a Lightsail instance in AWS using Ubuntu 22.04 with the requisite RAM and CPU
2. Grab a static IP address and don’t ever release it.
3. Assign it to the Lightsail host
4. Fully patch the host and open all the right ports. I also disable IPv6 on the Lightsail host
5. Install MIAB using all the default settings
6. Request reverse DNS and open Port 25 on AWS PROMISING that you host is not a relay server, can ONLY send email for your domain name. If they refuse, reply to them telling them again that you are setting up email for your own domain and x number of users and IT WILL NOT BE A SPAM RELAY Server - ergo… INSIST
7. Once RDNS is in place, try to send some emails to [hotmail.com](http://hotmail.com), [outlook.com](http://outlook.com), and others and see which fail. Note you test emails should have a proper subject line and copy the Lorem Ipsum test into the body. dont use all Capitals etc. Make the test emails as realistic as possible
8. Once MS start failing with a message that your IP block is blocked by them, contact Microsoft Robots and request “remediation” of the IP. The will always come back and say NO. but like AWS, send another message explaining the IP is a properly set up mail server that it NOT a relay, is fully DMARC compliant with SPF and DKIM enables and working etc etc etc. They may refuse twice, but insist they remediate

Then Presto, you have a fully functioning mail server with a good reputation.

It may take you 3-4 days to establish things to this point, but the message is, don’t give up when AWS or MS say no.

I now have 3 servers all running having gone thru this process and all work flawlessly.

The cost of the Static IP is negligible

---

<div class="post-metadata">

**Author:** ![AskinSavascisi](https://discourse.mailinabox.email/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@AskinSavascisi](https://discourse.mailinabox.email/u/AskinSavascisi)\
**Post date:** [July 21, 2025, 7:37pm UTC](https://discourse.mailinabox.email/t/digitalocean-with-sendgrid-smtp-relay/10204/9 "2025-07-21T19:37:36Z")

</div>

hi,

ive created servers till i got an ip which is not blocked on ALL platforms, im using it for 2 years and just checked on proofpoint and it isnt blocked there also 🙂

just my 2 cents, create “servers” till you get a good ip and then begin your miab or other mailserver installations.

kind regards.
