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:
- Firstly, connect to your VM using SSH using the following command:
gcloud compute ssh instance-name
- 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
- After that, we will modify the Postfix configuration options by opening the main.cf file:
sudo vi /etc/postfix/main.cf
- Now we can update the file as given below:
- We need to comment out the following lines:
# default_transport = error # relay_transport = error
- 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.
- After making the changes we can save the changes and close the file.
- We need to comment out the following lines:
- Now, we will create the SASL password map:
sudo vi /etc/postfix/sasl_passwd
- 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
- 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
- And remove the file that contains the credentials since it is no longer needed:
sudo rm /etc/postfix/sasl_passwd
- 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
- Finally, we can reload the configuration using the following:
sudo /etc/init.d/postfix restart
- We can install the
mailx
ormailutils
package and test our configuration.sudo apt -y install mailutils
- 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.
0 Comments