enough_mail icon indicating copy to clipboard operation
enough_mail copied to clipboard

How to setup and use the http/https/socks5 proxy to connect IMAP/POP3 server?

Open gzlock opened this issue 4 years ago • 7 comments
trafficstars

I checked the enough_mail document and no such content.

gzlock avatar Sep 05 '21 14:09 gzlock

What's your use-case? If you have set up a proxy on your system, this should be transparent to any network app as far as I understand....

robert-virkus avatar Sep 06 '21 08:09 robert-virkus

What's your use-case? If you have set up a proxy on your system, this should be transparent to any network app as far as I understand....

I'm chinese, my browser can open google.com when I use a proxy application image

But I follow the example(High Level API) and try to connect google server(gmail account), the console show connect dns.google.com timeout.

I tried it on the flutter windows desktop mode.

BTW, I used the ThunderBird mail application, I can’t login to gmail when I use it by default, but it provided the network proxy settings, and I set the proxy to 127.0.0.1:7890, it can login gmail.

gzlock avatar Sep 06 '21 15:09 gzlock

This seems to be an problem for Dart and Flutter, compare for example

  • https://github.com/flutter/flutter/issues/20376
  • https://github.com/dart-lang/sdk/issues/41376

I have found this GPL-licensed library that allows to connect via Socks5: https://github.com/v0l/socks5

One idea could be to abstract sockets in enough_mail and allow clients to specify a SocketFactory or similar.

Thoughts? Ideas? Suggestions?

robert-virkus avatar Sep 07 '21 13:09 robert-virkus

It can be done like the dio package, allowing proxy settings https://pub.dev/packages/dio#using-proxy

import 'package:dio/dio.dart';
import 'package:dio/adapter.dart';
...
(dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (client) {
  // config the http client
  client.findProxy = (uri) {
    //proxy all request to localhost:8888
    return 'PROXY localhost:8888';
  };
  // you can also create a new HttpClient to dio
  // return HttpClient();
};

gzlock avatar Sep 08 '21 18:09 gzlock

Dio just exposes the dart:io HttpClient's findProxy(Uri) callback. While I agree that this would be a nice API, I have no idea how to implement this. I cannot integrate with the above mentioned socks5 project, as that is licensed under the GPL-copy-left license and this does not mix with this project's MPL license. So either this would need to be re-implemented or solved differently.

The underlying question is:

  • how to connect with a Dart Socket through a socks5 proxy?

robert-virkus avatar Sep 08 '21 19:09 robert-virkus

I have a same question.. (maybe it's so late..? lol) How can i use socks proxy?

hsy159 avatar Jul 03 '23 08:07 hsy159

Has this problem been solved?

lwdsw avatar Oct 10 '23 16:10 lwdsw