Skip to main content

Connect to IMAP through Socks using Python asyncio

Dependencies

  • aioimaplib 1.0.1+
  • aiosocks 0.2.6+

Installation

pip install asocksimap

or

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())

Metadata

Release files for asocksimap 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asocksimap 1.0.4
File Size Uploaded
asocksimap-1.0.4.tar.gz 4.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for asocksimap 1.0.4
File Interpreter ABI Platform
asocksimap-1.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 10.8 kB

Release files / asocksimap-1.0.4.tar.gz

Download URL asocksimap-1.0.4.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ecdaa544d17e39997669078f0a71c0420362f4de6ce0355fc891fddac6e8cb01
BLAKE2b-256 checksum
How to use checksums
66ab4c3cb60c21cc742f644416c774e5e0aa27282d7247f7ef23e77ab39cc305
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Release files / asocksimap-1.0.4-py3-none-any.whl

Download URL asocksimap-1.0.4-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
467479b84b763061ba838848cc0487a19966a5da9d019032fca3c8fed141c30a
BLAKE2b-256 checksum
How to use checksums
0a6dbee261fa8cfaee983b295c400de782918b664a6fd90339384917620eac25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Release history Release notifications | RSS feed

This release

1.0.4 This release

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page