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-nameCopy Code
  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-modulesCopy Code
  3. After that, we will modify the Postfix configuration options by opening the main.cf file:
    sudo vi /etc/postfix/main.cfCopy Code
  4. Now we can update the file as given below:
    1. We need to comment out the following lines:
      # default_transport = error 
      # relay_transport = errorCopy Code
    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 = noanonymousCopy Code

      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_passwdCopy Code
  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_KEYCopy Code
  7. Next, we will use the postmap utility to generate a
    .dbCopy Code
     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.dbCopy Code
  8. And remove the file that contains the credentials since it is no longer needed:
    sudo rm /etc/postfix/sasl_passwdCopy Code
  9. Then we will set the following permissions on our
    .dbCopy Code
     file:
    sudo chmod 600 /etc/postfix/sasl_passwd.db 
    sudo ls -la /etc/postfix/sasl_passwd.db
    Copy Code
  10. Finally, we can reload the configuration using the following:
    sudo /etc/init.d/postfix restartCopy Code
  11. We can install the
    mailxCopy Code
     or 
    mailutilsCopy Code
    package and test our configuration.
    sudo apt -y install mailutilsCopy Code
  12. To send a test message we can use the following:
    echo 'Test passed.' | mail -s 'Test-Email' -aFrom:from-email destination-emailCopy Code

    We can also check our system’s logs for a status line containing

    statusCopy Code
     and the successful server response code 
    (250)Copy Code
    :

    sudo tail -n 5 /var/log/syslogCopy Code

[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.

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

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

0 Comments

Submit a Comment

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

Speed issues driving customers away?
We’ve got your back!