apiVersion: v1
kind: Pod
metadata:
  name: email-server
  labels:
    app: email-server
spec:
  terminationGracePeriodSeconds: 0
  containers:
    - name: email-server
      image: localhost:32000/msgsys-email
      ports:
        - name: smtp
          containerPort: 25
      command:
        - dumb-init
        - --
      args:
        - /bin/bash
        - -c
        - |
          exim -bdf -v -q30m &
          sleep 3
          # [Simple Mail Transfer Protocol - Wikipedia](https://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol)
          # [Simple Mail Transfer Protocol ietf.org/rfc/rfc2821.txt](https://www.ietf.org/rfc/rfc2821.txt)
          # [microHOWTO: Send an email using netcat](http://www.microhowto.info/howto/send_an_email_using_netcat.html)
          # [Send email with netcat - Stack Overflow](https://stackoverflow.com/questions/44250054/send-email-with-netcat)
          echo "======> SEND MAIL "
          function slowcat(){ while read; do sleep .5; echo "$REPLY"; done; }
          slowcat <<EOF | nc localhost 25
          HELO localhost
          MAIL FROM:bar@localhost
          RCPT TO:foo@localhost
          DATA
          From: bar@localhost
          To: foo@localhost
          Subject: Test
          Date: Thu, 31 Feb 2015 12:00:00 +0000
          
          Testing. Have a good day!

          .
          QUIT
          EOF
          sleep 2
          echo "======> READ MAIL "
          su - foo -c "echo p | mail"
          sleep 3000
          echo end
      resources:
        limits:
          memory: "512Mi"
          cpu: "500m"
