Bobcares

Configure Mailjet in Google Cloud – How to do

by | Jul 4, 2021

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

Here at Bobcares, we often handle requests from our customers to configure Mailjet 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 Mailjet in Google Cloud

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

Prerequisites for configuring Mailjet

Following are the prerequisites for this setup:

1. Firstly, we need to create a new Mailjet account.

2. Then get Mailjet SMTP account credentials.

3. After that we must ensure the email address we wish to send emails from has been validated.

4. Also we have to set up a firewall rule to allow TCP traffic on port 2525.

Configuring Mailjet as an SMTP relay Using Postfix

Following are the steps to configure Mailjet:

  1. Firstly, connect to your VM using SSH using the following command:
    gcloud compute ssh instance-name
  2. Then we must install the Postfix Mail Transport Agent on the VM using the following command:
    sudo apt update && sudo apt -y install postfix libsasl2-modules
  3. After that, we will modify the Postfix configuration options by opening the main.cf file:
    sudo vi /etc/postfix/main.cf
  4. Now we can update the file as given below:
    1. We need to comment out the following lines:
      # default_transport = error 
      # relay_transport = error
    2. And add the following lines to the end of the file:
      relayhost = in-v3.mailjet.com:2525
      smtp_tls_security_level = encrypt 
      smtp_sasl_auth_enable = yes 
      smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd 
      smtp_sasl_security_options = noanonymous

      Note: We must use port 2525 here since port 25 is not allowed on Compute Engine.

    3. After making the changes we can save the changes and close the file.
  5. Now, we will create the SASL password map:
    sudo vi /etc/postfix/sasl_passwd
  6. To the sasl_passwd file, we must add the following lines to provide the credentials for Mailjet:
    in-v3.mailjet.com:2525 YOUR_API_KEY:YOUR_SECRET_KEY
  7. Next, we will use the postmap utility to generate a .db file:
    sudo postmap /etc/postfix/sasl_passwd 
    sudo ls -l /etc/postfix/sasl_passwd*
    -rw------- 1 root root    68 Jun  1 10:50 /etc/postfix/sasl_passwd 
    -rw------- 1 root root 12288 Jun  1 10:51 /etc/postfix/sasl_passwd.db
  8. And remove the file that contains the credentials since it is no longer needed:
    sudo rm /etc/postfix/sasl_passwd
  9. Then we will set the following permissions on our .db file:
    sudo chmod 600 /etc/postfix/sasl_passwd.db 
    sudo ls -la /etc/postfix/sasl_passwd.db
    
  10. Finally, we can reload the configuration using the following:
    sudo /etc/init.d/postfix restart
  11. We can install the mailx or mailutils package and test our configuration.
    sudo apt -y install mailutils
  12. To send a test message we can use the following:
    echo 'Test passed.' | mail -s 'Test-Email' -aFrom:from-email destination-email

    We can also check our system’s logs for a status line containing status and the successful server response code (250):

    sudo tail -n 5 /var/log/syslog

[Need assistance? We can help you]

Conclusion

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

PREVENT YOUR SERVER FROM CRASHING!

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.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

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

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