namshi / docker-smtp

SMTP docker container
MIT License
548 stars 198 forks source link

mail command #66

Open matodrobec opened 4 years ago

matodrobec commented 4 years ago

Hello,

I would like to send mail from app service by using mail command like

echo "hello" | mail -s "test subject" -r from@test.com to@test.com

but this mail is not working.

If I use same mail command from smtp service then I am always get mail to mailbox.

If I use heirloom-mailx then it is working from app service

apt-get install heirloom-mailx
echo "This is the message body and contains the message" | heirloom-mailx -v -r "from@test.com" -s "This is the subject" -S smtp="smpt:25" to@test.com

My swarm configuration

docker stack deploy -c - smtp << EOF
version: '3.7'
services:
  smtp:
    image: namshi/smtp
    networks:
      - smtp
    environment:
      - RELAY_NETWORKS=:192.168.0.0/24:10.0.0.0/16
      - SMARTHOST_ADDRESS=${SMTP_HOST}
      - SMARTHOST_PORT=${SMTP_PORT}
      - SMARTHOST_USER=${SMTP_USER}
      - SMARTHOST_PASSWORD=${SMTP_PASSWORD}
    deploy:
      restart_policy:
          condition: any
      placement:
        constraints:
          - node.role == manager
networks:
  smtp:
    external: true
    name: smtp
EOF

docker stack deploy -c - mailtest << EOF
version: '3.7'

services:
  app:
    image: php7-fpm
    command: tail -f /dev/null
    networks:
      - smtp
    deploy:
      restart_policy:
        condition: any
      placement:
        constraints:
          - node.labels.role == web

networks:
  smtp:
    external: true
    name: smtp

EOF

Test with ssmtp

I try to install ssmtp on the app service but it is not working too.

apt-get install ssmtp

and set set up config like

> cat /etc/ssmtp/ssmtp.conf

root=postmaster
hostname=dc4285ba769a
mailhub=smtp:25

Thank you for help