<p>I have a mailhog pod and a mailer service running in Kubernetes. I am on an M1 machine, mailhog/mailhog was not running properly, so I changed it to jcalonso/mailhog, could this be a problem? The mailer service is unable to dial a TCP connection to the mailhog pod. The pod itself is running, and I am able to view the HTTP site with an ingress to port 8025. Here is my mailer service's yaml file:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: mail-service
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mail-service
  template:
    metadata:
      labels:
        app: mail-service
    spec:
      containers:
        - name: mail-service
          image: &quot;papaya147/mail-service:latest&quot;
          resources:
            requests:
              memory: &quot;64Mi&quot;
              cpu: &quot;250m&quot;
            limits:
              memory: &quot;128Mi&quot;
              cpu: &quot;500m&quot;
          env:
            - name: MAIL_DOMAIN
              value: &quot;&quot;
            - name: MAIL_HOST
              value: &quot;localhost&quot;
            - name: MAIL_PORT
              value: &quot;1025&quot;
            - name: MAIL_ENCRYPTION
              value: &quot;none&quot;
            - name: MAIL_USERNAME
              value: &quot;&quot;
            - name: MAIL_PASSWORD
              value: &quot;&quot;
            - name: FROM_NAME
              value: &quot;John Smith&quot;
            - name: FROM_ADDRESS
              value: &quot;admin@example.com&quot;
          ports:
            - containerPort: 80

---
apiVersion: v1
kind: Service
metadata:
  name: mail-service
spec:
  selector:
    app: mail-service
  ports:
    - protocol: TCP
      name: mail-port
      port: 80
      targetPort: 80

</code></pre>
<p>And here is the mailhog deployment:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: mailhog
spec:
  selector:
    matchLabels:
      app: mailhog
  template:
    metadata:
      labels:
        app: mailhog
    spec:
      containers:
        - name: mailhog
          image: jcalonso/mailhog
          resources:
            requests:
              memory: &quot;64Mi&quot;
              cpu: &quot;250m&quot;
            limits:
              memory: &quot;128Mi&quot;
              cpu: &quot;500m&quot;
          ports:
            - containerPort: 1025
            - containerPort: 8025
---
apiVersion: v1
kind: Service
metadata:
  name: mailhog
spec:
  selector:
    app: mailhog
  ports:
    - protocol: TCP
      name: mailhog-smtp-port
      port: 1025
      targetPort: 1025
    - protocol: TCP
      name: mailhog-web-port
      port: 8025
      targetPort: 8025

</code></pre>
<p>While testing with Docker Swarm, these environment variables worked. Below is a screenshot of the pods logs:
<a href="https://i.stack.imgur.com/Wnu7S.png" rel="nofollow noreferrer">image link.</a></p>

Papaya
<p>You are using <code>localhost</code> to access the <code>mailhog</code> service from your <code>mail-service</code> pod. You should be using a fully qualified domain name (FQDN) of the <code>mailhog</code> service in your mail-server's <code>MAIL_HOST</code> env variable.</p>
<p>FQDN of any service by default is typically in the format: <code>&lt;service-name&gt;.&lt;namespace&gt;.svc.cluster.local</code>. In this case, the FQDN of the mailhog service would be <code>mailhog.default.svc.cluster.local</code> or simply <code>mailhog.svc.cluster.local</code> since both the pods are in the same namespace (default)</p>
<p>Ref: <a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#a-aaaa-records" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#a-aaaa-records</a></p>
