Exploring Microsoft Azure Portal: Setting Up GitLab Runner and Poste.io Mail Server with Amazon SES for SMTP

Introduction

In today’s cloud-driven world, managing infrastructure with services like Microsoft Azure and AWS has become a vital part of software development and deployment. In this post, I’ll walk you through my recent experience exploring Microsoft Azure, where I set up a Virtual Machine (VM) to host GitLab Runner for continuous integration and Poste.io as a mail server. However, I encountered a common issue — outbound port 25 was blocked, which is essential for sending email via SMTP. To overcome this, I integrated Amazon Simple Email Service (SES) to handle outbound mail.

This blog post details how I set up these services and how Amazon SES solved the port 25 block issue on cloud infrastructure, providing a seamless email-sending solution.


Step 1: Exploring Microsoft Azure and Creating a Virtual Machine

The first step in the process was to create a Virtual Machine (VM) on Microsoft Azure, which would serve as the host for both GitLab Runner and the Poste.io mail server.

Why Azure?
Azure’s cloud platform offers powerful resources, scalability, and a wide range of services. Its Virtual Machines are versatile and support various operating systems, making it perfect for my needs.

Here’s a quick rundown of how I created the VM:

  1. Access the Azure Portal:
    • Go to the Azure Portal and log in with your credentials.
    • From the dashboard, select Virtual Machines in the side menu and click Create.
  2. Configuring the VM:
    • Choose an operating system (I used Ubuntu 20.04 for its stability and support).
    • Select the appropriate size for your VM based on your workload. I went with a Standard B2s VM, which offers 2 vCPUs and 4 GB of RAM — enough for GitLab Runner and Poste.io.
  3. Networking:
    • When setting up the VM’s networking options, ensure that you configure inbound rules for ports such as HTTP (80), HTTPS (443), and SMTP (587) for mail communication.
    • Once done, click Review + Create and then click Create to spin up your VM.
  4. Access the VM via SSH:
    • Once the VM is created, you’ll be given a public IP address. Use SSH to access your new VM:

      ssh <your-username>@<your-vm-ip-address>


Step 2: Setting Up GitLab Runner on Azure VM

With the VM ready, I proceeded to set up GitLab Runner — a key component for running CI/CD pipelines on GitLab.

  1. Install GitLab Runner: SSH into your VM and run the following commands to install GitLab Runner:

    curl -L –output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
    chmod +x /usr/local/bin/gitlab-runner
    gitlab-runner install
    gitlab-runner start


Step 3: Setting Up Poste.io as a Mail Server

Next, I turned my attention to setting up the mail server. For this task, I chose Poste.io, a fully-featured mail server that’s easy to install and configure.

  1. Installing Docker: Poste.io runs within a Docker container, so the first step is to install Docker on your VM:

    sudo apt-get update
    sudo apt-get install docker.io

  2. Setting Up Poste.io: With Docker installed, you can now set up the Poste.io mail server. Simply run the following command to pull the Poste.io Docker image and start the container:

    sudo docker run -d \
    –name “poste” \
    –restart=always \
    -p 25:25 -p 80:80 -p 443:443 -p 587:587 -p 110:110 -p 995:995 -p 143:143 -p 993:993 \
    -v /your-data-folder:/data \
    analogic/poste.io

    This will expose the necessary ports and mount the data folder for persistence. You can access the Poste.io admin interface by visiting the VM’s public IP address in a browser.

  3. Initial Configuration: Upon visiting your server’s IP in a browser, you’ll be prompted to configure the domain, admin account, and other initial settings. Once set up, you can start managing email accounts, domains, and mail queues directly through the Poste.io dashboard.

Step 4: Overcoming the Port 25 Block with Amazon SES for Outbound Mail

At this point, I ran into a common issue: Azure (and most cloud providers) block outbound traffic on port 25, the default port used for sending SMTP email. This meant my Poste.io server could not send outgoing mail.

The solution? Amazon Simple Email Service (SES) — a reliable, scalable service that bypasses port 25 restrictions and allows your server to send outbound emails.

Setting Up Amazon SES

  1. Log into the AWS Console: Head to the Amazon SES Console and create an SES account if you don’t have one already.
  2. Verify Your Domain:
    • Navigate to Domains under the SES dashboard.
    • Click Verify a New Domain and follow the steps to verify your domain. This may involve adding DNS records provided by SES to your domain’s DNS settings.
  3. Create SMTP Credentials:
    • In the SES console, under SMTP Settings, generate SMTP credentials (Amazon will provide a username and password).
    • Make note of the SMTP server endpoint (e.g., email-smtp.us-east-1.amazonaws.com) and the credentials.

Configuring Poste.io to Use Amazon SES

Now, you need to configure Poste.io to use Amazon SES as the SMTP route for outbound emails.

  1. Modify Default SMTP Route (used by Poste.io): Change target SMTP server hostname Amazon SES SMTP hostname together with the SMTP username and password,

At this point, your Poste.io mail server is configured to send emails through Amazon SES, circumventing the port 25 block.


Step 5: Conclusion

Setting up a Virtual Machine on Microsoft Azure to run GitLab Runner and Poste.io for mail services is a powerful combination for managing your CI/CD workflows and email communication. However, the outbound port 25 block on most cloud providers can be a major hurdle for email delivery.

By integrating Amazon SES with Poste.io, I was able to successfully configure SMTP services, ensuring reliable outbound mail delivery. This solution not only bypasses cloud provider restrictions but also offers a scalable and cost-effective way to manage email sending.

If you’re facing similar challenges in your own cloud-based mail server setups, I highly recommend looking into Amazon SES for your email-sending needs. It’s a robust and dependable solution to keep your communication flowing smoothly!


Have you set up similar cloud-based systems or dealt with SMTP restrictions? Share your experiences in the comments below!