Send email from a pipeline container, connect to host MTA by using host network

I need/want to send an email to the committer email once a release pipeline finishes.

I can use sendmail on the runner host as it has got a MTA configured. So, the idea was for the pipeline to start a container that includes sendmail. BUT for that to work the container has to be started using the host network i.e. with --net=host.

It does not seem possible to do that from within .gitlab-ci.yaml?


  # how to declare --net=host?
  image: docker #something
  stage: .post
  allow_failure: true
    - author_email=$(git log --pretty=format:"%ae" -1)
    - sendmail -v $(author_email)  < email.txt

Is my only option here to use a custom Docker image that contains ssntp and a configuration for a remote mailhub?

P.S. this is somewhat related to

Current workaround

        # need a minimal image with Git and sendmail, downside: need to overwrite the entrypoint
        name: alpine/git:v2.26.2
        entrypoint: [""]
      stage: .post
      allow_failure: true
        - AUTHOR_EMAIL=$(git log --pretty=format:"%ae" -1)
        # may not be necessary for you
        - export SMTPHOST=xxx
        - echo -e "Subject:Your $CI_PROJECT_NAME release\n\nyadayadayada\n" | sendmail -v -f "$AUTHOR_EMAIL"
        - master