# Connect to IMAP through Socks using Python asyncio
## Dependencies
- aioimaplib 1.0.1+
- aiosocks 0.2.6+
## Installation
```bash
pip install asocksimap
```
or
```bash
pip install git+https://github.com/optinsoft/asocksimap.git
```
## Usage
```python
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())
```
Raw data
{
"_id": null,
"home_page": "https://github.com/optinsoft/asocksimap",
"name": "asocksimap",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "socks,imap,asyncio",
"author": "optinsoft",
"author_email": "optinsoft@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/66/ab/4c3cb60c21cc742f644416c774e5e0aa27282d7247f7ef23e77ab39cc305/asocksimap-1.0.4.tar.gz",
"platform": null,
"description": "# Connect to IMAP through Socks using Python asyncio\r\n\r\n## Dependencies\r\n\r\n- aioimaplib 1.0.1+\r\n- aiosocks 0.2.6+\r\n\r\n## Installation\r\n\r\n```bash\r\npip install asocksimap\r\n```\r\n\r\nor\r\n\r\n```bash\r\npip install git+https://github.com/optinsoft/asocksimap.git\r\n```\r\n\r\n## Usage\r\n\r\n```python\r\nimport asyncio\r\nfrom asocksimap import AsyncSocksIMAP4_SSL\r\nfrom functools import reduce\r\n\r\ndef checkResponse(res, func):\r\n if res.result != 'OK':\r\n msg = reduce(lambda s, i: (s + \"\\n \" if i > 0 else \"\") + res.lines[i].decode('utf8'), range(len(res.lines)), \"\")\r\n if not msg: msg = f\"{func} failed\"\r\n raise Exception(msg) \r\n\r\nasync def aimap_test():\r\n email_address = 'YOUR_ACCOUNT@hotmail.com'\r\n password = 'YOUR_PASSWORD'\r\n imap_server = 'outlook.office365.com'\r\n imap_port = 993\r\n socks_addr = '127.0.0.1'\r\n socks_port = 1080\r\n socks_type = 'socks5'\r\n\r\n aimap = AsyncSocksIMAP4_SSL(host=imap_server, port=imap_port, timeout=15,\r\n proxy_addr=socks_addr, proxy_port=socks_port, proxy_type=socks_type)\r\n await aimap.wait_hello_from_server() \r\n res = await aimap.login(email_address, password)\r\n checkResponse(res, \"login\")\r\n res = await aimap.logout()\r\n checkResponse(res, \"logout\")\r\n\r\nloop = asyncio.get_event_loop()\r\nloop.run_until_complete(aimap_test())\r\n\r\n```\r\n",
"bugtrack_url": null,
"license": "",
"summary": "Connect to IMAP through Socks using Python asyncio",
"version": "1.0.4",
"project_urls": {
"Homepage": "https://github.com/optinsoft/asocksimap"
},
"split_keywords": [
"socks",
"imap",
"asyncio"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0a6dbee261fa8cfaee983b295c400de782918b664a6fd90339384917620eac25",
"md5": "c586ca20faf0e775a28b87b556209218",
"sha256": "467479b84b763061ba838848cc0487a19966a5da9d019032fca3c8fed141c30a"
},
"downloads": -1,
"filename": "asocksimap-1.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c586ca20faf0e775a28b87b556209218",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 5902,
"upload_time": "2023-11-04T04:33:54",
"upload_time_iso_8601": "2023-11-04T04:33:54.117355Z",
"url": "https://files.pythonhosted.org/packages/0a/6d/bee261fa8cfaee983b295c400de782918b664a6fd90339384917620eac25/asocksimap-1.0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "66ab4c3cb60c21cc742f644416c774e5e0aa27282d7247f7ef23e77ab39cc305",
"md5": "77ebee437bfcb4416974d72e0904f23a",
"sha256": "ecdaa544d17e39997669078f0a71c0420362f4de6ce0355fc891fddac6e8cb01"
},
"downloads": -1,
"filename": "asocksimap-1.0.4.tar.gz",
"has_sig": false,
"md5_digest": "77ebee437bfcb4416974d72e0904f23a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4947,
"upload_time": "2023-11-04T04:33:55",
"upload_time_iso_8601": "2023-11-04T04:33:55.596419Z",
"url": "https://files.pythonhosted.org/packages/66/ab/4c3cb60c21cc742f644416c774e5e0aa27282d7247f7ef23e77ab39cc305/asocksimap-1.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-04 04:33:55",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "optinsoft",
"github_project": "asocksimap",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "asocksimap"
}