Connect to IMAP through Socks using Python asyncio
Project description
Connect to IMAP through Socks using Python asyncio
Installation
pip install git+https://github.com/optinsoft/asocksimap.git
Usage
import asyncio
from asocksimap import AsyncSocksIMAP4_SSL
from functools import reduce
def checkResponse(res, func):
if res.result != 'OK':
msg = reduce(lambda s, i: (s + "\n " if i > 0 else "") + res.lines[i].decode('utf8'), range(len(res.lines)), "")
if not msg: msg = f"{func} failed"
raise Exception(msg)
async def aimap_test():
email_address = 'YOUR_ACCOUNT@hotmail.com'
password = 'YOUR_PASSWORD'
imap_server = 'outlook.office365.com'
imap_port = 993
socks_addr = '127.0.0.1'
socks_port = 1080
socks_type = 'socks5'
aimap = AsyncSocksIMAP4_SSL(host=imap_server, port=imap_port, timeout=15,
proxy_addr=socks_addr, proxy_port=socks_port, proxy_type=socks_type)
await aimap.wait_hello_from_server()
res = await aimap.login(email_address, password)
checkResponse(res, "login")
res = await aimap.logout()
checkResponse(res, "logout")
loop = asyncio.get_event_loop()
loop.run_until_complete(aimap_test())
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
asocksimap-1.0.0.tar.gz
(3.6 kB
view hashes)
Built Distribution
Close
Hashes for asocksimap-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6815aab9c6ea3538573bda98525a5cc196b596e0ab0e5862990f2886c7ef61e |
|
MD5 | bbe1cbc24190a51a1df2214bdc5bf708 |
|
BLAKE2b-256 | ff65384c4fe36b3bdfe69ca8940cbbb55143fde272d628d1ed1285ab53ba1e2d |