Call Us! 1-800-383-5193
Call Us! 1-800-383-5193
Call Us! 1-800-383-5193

Need Help?

Emergency Response Time custom

Our experts have had an average response time of 11.06 minutes in March 2021 to fix urgent issues.

We will keep your servers stable, secure and fast at all times for one fixed price.

Configure SendGrid in Google Cloud – How to do

by | Jul 4, 2021

Wondering how to Configure SendGrid in Google Cloud?  We can help you.

Here at Bobcares, we often handle requests from our customers to configure SendGrid on their GCP as a part of our Server Management Services.

Today we will see how our Support Engineers do this for our customers.

How to configure SendGrid in Google Cloud

Now we will see the steps that our Support Engineers follow for this setup.

Prerequisites for configuring SendGrid

Following are the prerequisites for this setup:

1. Firstly, in the Cloud Console, go to the VM instances page and click Create instance.

2. Then we can set Name to sendgrid-tutorial.

3. After that in the Boot disk section click Change.

4. Now, on the Public images tab, we can select a Debian or CentOS image version.

5. And click Select.

6. Finally, we can click Create to create the instance.

7. We can use the Google Cloud Marketplace to sign up for the SendGrid email service. The SMTP username and password are the same as what we use to sign up for the service.The SendGrid hostname is

8. Next, we will create an API key using the following steps:

a) Sign in to SendGrid and go to Settings, then take API Keys.

b) And create an API key.

c) After that, we have to select the permissions for the key. At least, the key should have Mail send permissions to send an email.

b) Finally, click Save to create the key.

Since this is the only copy of the key, we have to ensure that we copy the key and save it for later.

Sending mail from the instance with Postfix

Complete the following steps to connect to the sendgrid-tutorial instance and run SendGrid with Postfix.

Connecting to the instance using SSH

For connecting the sendgrid-tutorial we created earlier we can use the following steps:

1. From the Cloud Console, go to the VM instances page.

2. In the list of virtual machine instances, we need to click SSH in the row of the instance that we want to connect.

Configuring SendGrid as an SMTP relay with Postfix

We can run the following commands in our SSH terminal to use SendGrid as an SMTP relay with Postfix.

  1. First, to become a superuser we can use the following command:
    sudo su -
  2. Then set a safe umask using the following command:
    umask 077
  3. Now we can Install the Postfix Mail Transport Agent:
    apt update && apt -y install postfix libsasl2-modules

    If prompted, we must select the Local Only configuration and accept the default domain name.

  4. After that, we can modify the Postfix configuration options by opening /etc/postfix/ for editing.
    nano /etc/postfix/
  5. We must update the file as given below:
    1. Comment out the following lines:
      # default_transport = error
      # relay_transport = error
    2. Add the following lines to the end of the file:
      relayhost = []:2525
      smtp_tls_security_level = encrypt
      smtp_sasl_auth_enable = yes
      smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
      header_size_limit = 4096000
      smtp_sasl_security_options = noanonymous
  6. After making the changes in configuration, we can Save and close the file.
  7. Now, generate the SASL password map using the API key we generated in the section.
    echo []:2525 apikey:your-api-key >> /etc/postfix/sasl_passwd
  8. Use the postmap utility to generate a .db file:
    postmap /etc/postfix/sasl_passwd
  9. Verify that there is a .db file using the following command:
    ls -l /etc/postfix/sasl_passwd*
    -rw------- 1 root root    ...  /etc/postfix/sasl_passwd
    -rw------- 1 root root    ...  /etc/postfix/sasl_passwd.db
  10. Remove the file containing the credentials because it is no longer needed:
    rm /etc/postfix/sasl_passwd
  11. Set the permissions on the .db file and verify that the other file was removed:
    chmod 600 /etc/postfix/sasl_passwd.db
    ls -la /etc/postfix/sasl_passwd.db
    -rw------- 1 root root    ...  /etc/postfix/sasl_passwd.db
  12. After that we can reload our configuration to load the modified parameters:
    /etc/init.d/postfix restart
  13. Install the mailutils or mailx package:
    apt -y install mailutils
  14. Send a test email:
    echo 'message' | mail -s subject
  15. Finally, we can  check the system logs for a status line containing status and the successful server response code (250):
    tail -n 5 /var/log/syslog

[Need assistance? We can help you]


To conclude, we saw the steps that our Support Techs follow to Configure SendGrid in Google Cloud for our customers.


Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.


var google_conversion_label = "owonCMyG5nEQ0aD71QM";


Submit a Comment

Your email address will not be published. Required fields are marked *

Privacy Preference Center


Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]


Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid


Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie


These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.