Skip to content

Instantly share code, notes, and snippets.

@anviar
Created January 30, 2019 13:19
Show Gist options
  • Save anviar/706340a8f096a45494f6c88773dedd2d to your computer and use it in GitHub Desktop.
Save anviar/706340a8f096a45494f6c88773dedd2d to your computer and use it in GitHub Desktop.
Idea how to deliver mails to telegram channel
#!/usr/bin/env python3
import email
import sys
import telegram
import logging
logging.basicConfig(
format='[%(levelname)s] %(message)s',
level=logging.DEBUG)
msg = email.message_from_file(sys.stdin)
print(msg.get('Subject'))
for part in msg.walk():
print(type(part))
print(part.get_payload())
t_bot = telegram.Bot(
token='775162133:AAFL6gJIXjwfna63d-KoDarhVzK54erhatrhfwffpHmuc',
request=telegram.utils.request.Request(
proxy_url='socks5://111.222.333.444:1234',
urllib3_proxy_kwargs={
'username': 'user',
'password': 'password'
}
)
)
t_bot.send_message(
chat_id=-1001207333772,
text=msg.get('Subject'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment