Sending mail via Sendgrid Web API

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 to MIAB via a terminal in my MAC virtual machine do I still need to download curl?

Step 2 looks easy, just click on the Create Key button.

Step 3 looks like I have to export the API key I created in step 2 from my MAC VM to my MIAB.
I have never exported anything into my MIAB so I don’t know how.

Step 4 looks like I have to ssh into my MIAB and run those commands.

Then after all that I have to click on Verify Integration.

Thank you in advanced!!

Sendgrid support is not very helpful, that’s why I’m here :slight_smile:

Please confirm – you only want to relay mail via SendGrid, correct? You are not looking at using them to maintain a mailing list (at least at this moment) I presume?

If the answer to the first question is relay, then the only suitable choice is ‘SMTP Relay’. The other choice is if you are creating and sending html marketing type emails from the command line (ugh) or using an API which would be something more likely with software such as Mailtrain or Sendy.

Yes, I want only to relay mail via Sendgrid.
OK. I will choose SMTP Relay.
Thanks Alento!

This is the page I get after choosing integration by SMTP Relay:

Step 1: Easy.
Step 2: Does “Configure your application with the settings below” means configure those settings in the email client of my choice (ie. Thunderbird, Outlook)?
What about the users that use webmail?


No. It means to make an unsupported modification to your MiaB server. See here:


I just found this info on Sendgrid:

Are those two guides the “same” thing? Which one should I follow?


Yes, basically. The one I linked uses STARTTLS which MiaB uses, so I would stick with it.

Got it. Thanks Alento!

I gotta be honest - I tried setting up relaying on a test box and did not do so well … I am going to try it again (tomorrow maybe?) so let me know how it goes for you. I think that the issues I had were specific to the smtp server that I wanted to relay through, but haven’t tried a different server, yet …

Let me expand on the issue … I kept getting timeouts when attempting to send mail via the relay. Reverting the changes I made everything worked normally.

So, should I do a droplet snapshot on digital ocean before performing those steps or not necessary?

It is always a good idea if you are not super experienced at this kind of changes to do so … that said, it shouldn’t be necessary - but I’d err on the side of caution.

The biggest risk is that something goes terribly wrong while editing the configuration file of Postfix … but that truly has a low probability of happening.

But again, if you are on DO - it does not hurt since it is so easy to do! :slight_smile:

On my way to DO…

On my way to bed as I am likely several time zones ahead of you. :slight_smile: We can touch base tomorrow here, or on Slack.

Just for fun, I followed the sendgrid guide for postfix but nothing happened.
Sendgrid support replied today with:

“For the message you sent out, there was not any record of it being received by our servers which means there is most likely an error within your authentication of SMTP.”

Now, I’d like to follow the real deal (Alento’s link above).
Do I have to follow everything or just this part:

``` ```
# enable SASL authentication
smtp_sasl_auth_enable = yes
# disallow methods that allow anonymous authentication.
smtp_sasl_security_options = noanonymous
# where to find sasl_passwd
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
# Enable STARTTLS encryption
smtp_use_tls = yes
# where to find CA certificates
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt


As mentioned above … all but the INSTALLING POSTFIX portion.

But first - would you share your Postfix file that you are using now to try relaying via SendGrid? You can post it here, or at and advise what the link is.

And just curious … what did mail.log say about the message you attempted to send?
(we can move this to Slack if you prefer)

In /var/log With vi mail.log I’m seeing info for Jun 3
How do I get to Jun4?

Use less

less /var/log/mail,log

and keep paging down (space bar) until you get to June 4. There are easier ways, but I am not overly knowledgeable concerning the proper syntax. Grep comes to mind… even using ctrl-w in nano … so many possible ways, but I am not a master of any (I actually use log viewer in Webmin).

Alento, besides slack where can I show you the Mail.log

Maybe or similar.