KostyaEsmukov / smtp_to_telegram

A small program that listens for SMTP and sends all incoming Email messages to Telegram
MIT License
316 stars 76 forks source link

Lookup api.telegram.org connection refused. #18

Closed MenchenFive closed 3 years ago

MenchenFive commented 3 years ago

Trying to set this up on my OpenMediaVault NAS, in order to tunnel all email notifications (OMV, torrent, etc...) to telegram. However, whenever I try to send a test email, the whole thing just enters in an endless loop, prompting the following messages over and over again in a really fast manner:

telegram_smtp         | time="2021-04-02T21:54:19Z" level=debug msg="[127.0.0.1:52525] Waiting for a new client. Next Client ID: 334"
telegram_smtp         | time="2021-04-02T21:54:19Z" level=info msg="Handle client [127.0.0.1], id: 333"
telegram_smtp         | time="2021-04-02T21:54:19Z" level=debug msg="Writing response to client: \n220 mnxn SMTP Guerrilla(unknown) #333 (1) 2021-04-02T21:54:19Z\r\n"
telegram_smtp         | time="2021-04-02T21:54:19Z" level=debug msg="Client sent: EHLO mnxn.localdomain"
telegram_smtp         | time="2021-04-02T21:54:19Z" level=debug msg="Writing response to client: \n250-mnxn Hello\r\n250-SIZE 10485760\r\n250-PIPELINING\r\n250-ENHANCEDSTATUSCODES\r\n250 HELP\r\n"
telegram_smtp         | time="2021-04-02T21:54:19Z" level=debug msg="Client sent: MAIL FROM:<asdf@test.test>"
telegram_smtp         | time="2021-04-02T21:54:19Z" level=debug msg="Writing response to client: \n250 2.1.0 OK\r\n"
telegram_smtp         | time="2021-04-02T21:54:19Z" level=debug msg="Client sent: RCPT TO:<asdf@test.test>"
telegram_smtp         | time="2021-04-02T21:54:19Z" level=debug msg="Writing response to client: \n250 2.1.5 OK\r\n"
telegram_smtp         | time="2021-04-02T21:54:19Z" level=debug msg="Client sent: DATA"
telegram_smtp         | time="2021-04-02T21:54:19Z" level=debug msg="Writing response to client: \n354 Enter message, ending with '.' on a line by itself\r\n"
telegram_smtp         | time="2021-04-02T21:54:19Z" level=error msg="Post https://api.telegram.org/bot***/sendMessage?disable_web_page_preview=true: dial tcp: lookup api.telegram.org on [::1]:53: read udp [::1]:35014->[::1]:53: read: connection refused"
telegram_smtp         | time="2021-04-02T21:54:19Z" level=debug msg="Writing response to client: \n554 Error: Post https://api.telegram.org/bot***/sendMessage?disable_web_page_preview=true: dial tcp: lookup api.telegram.org on [::1]:53: read udp [::1]:35014->[::1]:53: read: connection refused\r\n"
telegram_smtp         | time="2021-04-02T21:54:19Z" level=debug msg="Client sent: QUIT"
telegram_smtp         | time="2021-04-02T21:54:19Z" level=debug msg="Writing response to client: \n221 2.0.0 Bye\r\n"
telegram_smtp         | time="2021-04-02T21:54:19Z" level=debug msg="[127.0.0.1:52525] Waiting for a new client. Next Client ID: 335

and on an on...

My config is the following. I assume the bug is due to the network_mode : host, but I need to set it up this way so I can send emails from OMV itself.


    image: kostyaesmukov/smtp_to_telegram
    container_name: telegram_smtp
    network_mode: host
    restart: always
    environment:
      - ST_SMTP_LISTEN=127.0.0.1:52525
      - ST_TELEGRAM_CHAT_IDS=POTATO
      - 'ST_TELEGRAM_BOT_TOKEN=POTATO:POTATOPOTATOPOTATOPOTATO'
MenchenFive commented 3 years ago

I am such an idiot. At first I thought it was some sort of DNS issue, so I changed my config to:

    image: kostyaesmukov/smtp_to_telegram
    container_name: telegram_smtp
    restart: always
    dns:
      - 1.1.1.1
      - 8.8.8.8
    ports: 
      - 52525:2525
    environment:
      - ST_TELEGRAM_CHAT_IDS=POTATO
      - 'ST_TELEGRAM_BOT_TOKEN=POTATO'

It still didn't work; but, a lightbulb shined above my head, and so I then tried setting up the user (1000:100, which is my docker user for openmediavault); and fixed it completely.

    image: kostyaesmukov/smtp_to_telegram
    container_name: telegram_smtp
    restart: always
    user: 1000:100
    ports: 
      - 52525:2525
    environment:
      - ST_TELEGRAM_CHAT_IDS=POTATO
      - 'ST_TELEGRAM_BOT_TOKEN=POTATO'

Hope this helps somebody in the future. Closing the issue. PBCAK error