For some reasons, I have to use a SOCKS proxy to access Gmail, otherwise, the connection will be blocked.

I tried the global SOCKS agent, and the worked fine. Nevertheless, when I turned to use a PAC file to configure system agent automatically, the wasn't able to access Gmail.

My questions:

  1. Is it possible to set proxy in That is, passes its web traffic to the SOCKS proxy while other apps won't be influenced.
  2. If the answer to the first question is NO, then how to modify my PAC file to make possible to access Gmail?

Any clues or suggestions would be appreciated.

More info:

OS version: OS X 10.9.5 version: 7.3 (1878.6)

The PAC file:

var domains = {
  "": 1,
  "": 1,
  "": 1,  
  "": 1, 
  "": 1, 
  "": 1, 
  "": 1, 
  "": 1, 
  "": 1, 
  "": 1, 
  "": 1, 
  "": 1, 
  "": 1, 
  "": 1, 
  "": 1, 
  "": 1

var proxy = "SOCKS5; SOCKS; DIRECT;";

var direct = 'DIRECT;';

function FindProxyForURL(url, host) {
    var lastPos;
    do {
        if (domains.hasOwnProperty(host)) {
            return proxy;
        lastPos = host.indexOf('.') + 1;
        host = host.slice(lastPos);
    } while (lastPos >= 1);
    return direct;

migrated from Jan 22 '15 at 10:21

This question came from our site for professional and enthusiast programmers.

  • exactly same problem here. Looks like, doesn't interact with the pac file. But in my case, I've made this test: Before I open I've a terminal window showing the log of the server that serves my pac file, and I'm able to see that it load the pac. But doesn't delivers the traffic to the proxy. If I use Network settings-> Socks then it works. Have you solved it ? – MiQUEL Feb 2 '15 at 18:11

Try go to Network Preferences, select the network you want to set, and go to Advanced -> Proxies. Then, set both Automatic Proxy Configuration and SOCKS proxy. It works for me.

FYI, if you're using Shadowsocks the PAC would probably be

  • Thank you for the answer, but I'd tried this before I posted this question. Unfortunately, however, the pac file failed to pass the traffic of Apple Mail into the socks tunnel. Indeed, set both PAC and Socks proxy would help, but I'm afraid this should only be owing to the Socks proxy. Nonetheless, socks proxy get all the web traffic by setting Socks Proxy in Network Pref., which is not I want. – Ch'en Meng Jan 12 '15 at 13:17

I know this thread is old, but I had the same problem thanks to the great firewall. I didn't want to route ALL of my traffic through my proxy, so setting this in network preferences was not an option.

I thought the problem was because of the Mail app on mac, but actually it was just access to the IMAP and SMTP gmail servers.

For whatever reason, the main GFW list doesn't include these. All you need to do is add these two lines to your PAC file:

||^ ||^

As soon as I added those, the mail app was working with gmail. I hope this works for you!

New contributor
user1865275 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • Wow! Thanks for your information! I'll try this later this night! – Ch'en Meng Dec 13 at 8:29
  • Let me know if it works! Update: I started having problems again, so I switched to outlook. Outlook had no problems at all and always gets my gmail messages. I think the Mail app itself does something strange. – user1865275 2 days ago

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.