Yahoo! Mail IMAP Proxy 61



UPDATE: It was fun, but this proxy is no longer needed. You can connect directly to Yahoo! via IMAP with the following servers:

imap.mail.yahoo.com port 993 (SSL)
smtp.mail.yahoo.com port 465 (SSL)


There are a few Yahoo! Mail IMAP proxies out there (YPOPS!, FreePOPs), but to be honest, I haven’t had much luck with either of them.  Additionally, switching webmail interfaces to Asia or Classic or whatever can be a bit of a hassle.

Yahoo! supports IMAP on some mobile devices, and now also allows it for anyone using the Zimbra mail client.  Unfortunately, I’m not too fond of that client and much prefer my Thunderbird; too bad it isn’t natively supported.

Luckily, Yahoo’s IMAP implementation isn’t too far off from what other clients recognize; it simply requires a "ID ("GUID" "1")"  to be issued before logging in.  No clients do that (except for these hacked up versions of Thunderbird), so my workaround was to create a simple IMAP proxy.

This proxy simply takes the commands sent to it by your mail client, passes them on to Yahoo, and relays them back to your client.  It all the while looks for your client to issue a "login" command so that it can inject the "id" command to unlock IMAP access.

This program is written in C and has been tested on Linux and Windows (via Cygwin). Read the release notes in the source for more information.  I haven’t written in C for a while, and I know that this program can be improved.  If anyone does so, I’d like to hear from you.


Connection settings:
Username: [email protected]
Hostname: localhost
Port: 3490
SSL: off

Download latest source

Download Windows Cygwin version


View Google Code Homepage


Leave a comment

Your email address will not be published. Required fields are marked *

61 thoughts on “Yahoo! Mail IMAP Proxy

  • trae_z

    hey i’m really sorry to bother you but please can you explain this succinctly step by step by step for the not so computer-wise how exactly this is done (or point me somewhere that it is explained). i’m talking about IMAP and SMTPs access for yahoo. thanks in advance. would appreciate if you email me back your response.

  • Ameir Abdeldayem

    I compiled a version that works in Windows via Cygwin. The download link is in the article. Simply extract all the files into the same location and double-click on yahooproxy.exe. You should see a command prompt window pop up.

    In your mail client, configure it for IMAP on server “localhost” on port 3490. For SMTP, use smtp.mail.yahoo.com with SSL enabled.

    When you poll the server you should see all the activity in the command prompt window. If I have time in the future, maybe I’ll make things sexier, but for now, this will do.

    Let me know if you have any questions.

  • Roger Stern

    Thanks so much for doing this. It works like a charm for Thunderbird, but Outlook gets an unreconized imap response error. Any idea why?

  • Roger Stern

    Ameir, I’ve been waiting a long time for something like this. Thanks for doing it.It works like a charm for Thunder bird but fails with Outlook. Outlook says it is getting an unreconized resopnse from the server. And Yproxy is reporting a proxy error. Any idea why?

  • sam

    @Ameir : that’s awesome :) is there any way to use it on a Mac ? I’d love to be able to use Mail.app from Apple, rather than a modified version of Thunderbird.

    thanks !

  • Ameir Abdeldayem

    Hi Sam,
    You should be able to compile it without issues on a Mac using GCC. I unfortunately don’t have one on-hand to test this out. Here is a gcc install guide; just treat it like Linux:
    http://www.google.com/search?q=gcc+mac	

    You’ll be using gcc from the Terminal (Applications->Utilities->Terminal). Please let me know how you fare.

  • sam

    Thanks !

    i got it to compile with this error

    $ gcc yahooproxy.c -o yahooproxy
    yahooproxy.c: In function ‘main’:
    yahooproxy.c:238: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘size_t’
    yahooproxy.c:285: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘size_t’
    $

    then I chmod’ed it, and launched.

    I set up Apple’s Mail with localhost server and 3490 port.

    It logs on apparently but nothing in inbox is showing up/no IMAP folders.

    i got those messages in terminal

    $ yahooproxy ; exit;
    server: waiting for connections…
    server: got connection from ::1
    server: got connection from ::1
    Connected to imap.mail.yahoo.com
    Connected to imap.mail.yahoo.com
    [Chunk 1]: message length = 40 40
    [imap.mail.yahoo.com]: * OK IMAP4rev1 server ready (3.5.62.7)

    out of loop
    [::1]:
    [Chunk 1]: message length = 40 40
    [imap.mail.yahoo.com]: * OK IMAP4rev1 server ready (3.5.62.7)

    out of loop
    [::1]:

    not sure what to do next.

    i appreciate your help, Ameir :)

  • FireStorm

    Using Outlook 2010 and Windows 7 x32 it produces errors.

    Additionally please provide the proper ports/auth settings I should use trying to get into my 2 Yahoo accounts using IMAP and your app.

    Thanks

  • Ameir Abdeldayem

    I will try to get my hands on a Mac so I can debug this further. I’m not sure what differences there are between Linux and Mac’s gcc.

  • Ameir Abdeldayem

    The program supports multiple connections as-is, so you should be able to use both accounts with the same connection settings without any issues.
    Server: localhost
    Port: 3490

  • Adam

    Now that’s a really neat idea! But it’s probably easier for people to use in Java, see below. Only done basic testing so far.

    [geshi lang=java]
    package yahooProxy;

    import java.net.*;
    import java.io.*;
    import java.util.regex.*;

    public class Main
    {
    private final static int LISTEN_PORT = 3490;
    private final static String TARGET_NAME = “imap.mail.yahoo.com”;
    private final static int TARGET_PORT = 143;
    private final static String ID_COMMAND = “2 id (\”GUID\\” \”1\\”)”;
    private final static Pattern LOGIN_COMMAND = Pattern.compile(“^\\d+\\s+login”, Pattern.CASE_INSENSITIVE);

    public static void main(String[] args) throws IOException
    {
    ServerSocket lServerSocket = null;

    try
    {
    lServerSocket = new ServerSocket(LISTEN_PORT);
    }
    catch (IOException e)
    {
    System.err.println(“Could not listen on port: ” + LISTEN_PORT);
    System.exit(1);
    }

    while (true) new ServerThread(lServerSocket.accept()).start();

    //lServerSocket.close();
    }

    public static class ServerThread extends Thread
    {
    private Socket mClientsocket = null;
    private Socket mServerSocket = null;

    public ServerThread(Socket iSocket)
    {
    super(“ServerThread”);
    mClientsocket = iSocket;

    try
    {
    mServerSocket = new Socket(TARGET_NAME, TARGET_PORT);
    }
    catch (UnknownHostException e)
    {
    System.err.println(“Failed to resolve name ” + TARGET_NAME);
    System.exit(1);
    }
    catch (IOException e)
    {
    System.err.println(“Failed to open socket to ” + TARGET_NAME + “:” + TARGET_PORT);
    System.exit(2);
    }

    System.out.println(“Opened new socket to ” + TARGET_NAME + “:” + TARGET_PORT);
    }

    public void run()
    {
    try
    {
    PrintWriter lServerOut = new PrintWriter(mServerSocket.getOutputStream(), true);
    BufferedReader lServerIn = new BufferedReader(new InputStreamReader(mServerSocket.getInputStream()));
    PrintWriter lClientOut = new PrintWriter(mClientsocket.getOutputStream(), true);
    BufferedReader lClientIn = new BufferedReader(new InputStreamReader(mClientsocket.getInputStream()));

    String lServerLine;

    main_loop: while (true)
    {
    do
    {
    lServerLine = lServerIn.readLine();
    if (lServerLine == null) break main_loop;
    Debug(“Server: ” + lServerLine);
    lClientOut.println(lServerLine);
    } while (lServerIn.ready());

    String lClientLine = lClientIn.readLine();
    if (lClientLine == null) break main_loop;
    Debug(“Client: ” + lClientLine);

    if (LOGIN_COMMAND.matcher(lClientLine).find())
    {
    Debug(“INJECTING: ” + ID_COMMAND);
    lServerOut.println(ID_COMMAND);
    do
    {
    lServerLine = lServerIn.readLine();
    if (lServerLine == null) break main_loop;
    Debug(“Server: ” + lServerLine);
    } while (lServerIn.ready());
    }

    lServerOut.println(lClientLine);
    }

    lServerOut.close();
    lServerIn.close();
    mServerSocket.close();
    lClientOut.close();
    lClientIn.close();
    mClientsocket.close();
    }
    catch (IOException e)
    {
    e.printStackTrace();
    }
    }

    private void Debug(String iInput)
    {
    //System.out.println(iInput);
    }
    }
    }
    [/geshi]

  • Marcel Bokhorst

    First of all thanks for creating this proxy!

    With the help some others I have created a package for the [url=http://trac.freetz.org/]Freetz[/url] platform (see [url=http://www.ip-phone-forum.de/showthread.php?t=216517]here[/url] for details).

    To make things work with Evolution I changed this line:

    [geshi lang=C]if (strstr(buffer, “login”) != NULL || strstr(buffer, “LOGIN”) != NULL) {[/geshi]

    [quote]Sometimes messages don’t load entirely due to the way I check for a complete message from the server (“OK” and “completed”)[/quote]

    What is exactly the problem? How can this be improved?

    Could you make available a download in zip or tar.gz format with a folder containing the source compressed. The Freetz package is now based on a quick and dirty hack, because currently only a plain source is available for download. And to improve things, maybe you can add a version number too.

  • Bark of Delight

    This worked for me on a Mac running Eudora, but not for the regular Apple Mail program. This leads one to suspect that Apple’s program is doing something unexpected.

    In particular, as soon as I set the account email to an [email protected], Apple’s Mail program indicated that the account was now of type “Yahoo IMAP” (as opposed to just “IMAP”). This suggests that Apple Mail has *some* support for Yahoo IMAP, although it doesn’t allow choosing that directly.

    When I get some time I’ll try to debug what is going wrong with this proxy solution w/ Apple Mail. In any case, it’s great to have a method to archive my Yahoo! email as sadly there is no export or archive supplied by Yahoo!

    I don’t want this to turn into a Yahoo! bash, but I myself am leaving Yahoo. They appear to be stuck in the 20th century.

    Bark!

  • Bark of Delight

    Ok, I have found that the problem with Apple Mail and this proxy program is in fact the hello banner. In particular, this line of the code:

    clientmsg(new_fd, “Welcome to Yahoo! IMAP Proxy!\r\n”);

    is tripping up Apple Mail somehow. Commenting out that line (and following the above suggestion of matching “LOGIN” as well as “login”) fixes the problem.

    This is terrific. Thanks again for writing this.

    Bark!

  • sam

    Hi Bark of Delight,
    could you upload this file somewhere and post the link ?
    it really doesn’t work, even after commenting out the Hello line, i still have the same issues as I wrote in the comments a few days ago.
    ie : it doesn’t work at all in Apple Mail :-(
    Thanks :)
    sam

  • Ameir Abdeldayem

    I’ve made some changes to the proxy and updated the links in the article. Please try the new version and let me know if it works for you.

  • Ameir Abdeldayem

    Thanks for the “LOGIN” tip; that enabled several other clients to work.

    The problem with checking for a complete message is that sometimes “OK” and “completed” don’t show in the same buffer window, so your email client may lag for a bit before it retries (if it does retry). I’m not sure at this point what other solution there is to this. I’m open to any ideas.

    There is a zip of the source code in the article (bundled with cygwin). What would you like to see in the archive? Are you looking for a Makefile?

    I’ve added version numbers and uploaded the source to Google Code; that should help keep things organized.

  • sam

    cool, it works now !
    thanks !

    i posted the compilation issue on GoogleCode, it’d be easier to find and fix it there i think.

    i don’t know how to run that as a daemon in the background, to ba as transparent as possible.

    Bark of Delight, you seem to know a lot about OSX, do you have any clue ?

    thanks a LOT guys, that’s awesome !

  • Ameir Abdeldayem

    On Linux (and likely OS X), you can run the proxy in the background by using nohup.

    Try this:

    nohup ./yahooproxy &

  • syrou

    Thanks for this fine piece of app. BTW, would it be possible to chain-proxy it’s output? I’m behind an SSH tunnel with a dynamic socks proxy defined.

  • George

    Ameir, thanks again for putting this up. In my first connections to yahoo the connection times out. I have a lot of email data to download and maybe it has to do with the “OK” or “Complete” thing you mentioned. I am using KMail. But I expect after I download everything for it to work fine.

    To Adam if he is listening. The java program fails to download anything, although I can view the folders in the imap account. Maybe fixing the “login” fixes this?

    Thanks,
    George

  • Mike

    I’ve got the compiled Windows version working in Windows 7 with Outlook 2007 talking to my two Outlook mailboxes. I can read and delete mail in any folder in either mailbox. I can move mail between folders in the same maibox or out of that IMAP mailbox to Outlook personal folders.

    What I cannot do is move anything into a new folder in different mailbox. Outlook tries then fails with “APPEND ERROR”. In the proxy window, I see:

    [Chunk 4]: message length = 0 0
    Detected 1 blank message(s)
    [imap.mail.yahoo.com]:
    [Chunk 5]: message length = 0 0
    Detected 2 blank message(s)
    [imap.mail.yahoo.com]:
    [Chunk 6]: message length = 0 0
    Detected 3 blank message(s)
    [imap.mail.yahoo.com]:
    [Chunk 7]: message length = 0 0
    Detected 4 blank message(s)
    [imap.mail.yahoo.com]:
    [Chunk 8]: message length = 0 0
    Detected 5 blank message(s)
    [imap.mail.yahoo.com]:
    [Chunk 9]: message length = 0 0
    Detected 6 blank message(s)
    server: closing connection with ::1
    [Chunk 2]: message length = 79 79
    [imap.mail.yahoo.com]: rs4t NO APPEND error; internal server error. Please try
    again after some time

  • Dan

    OP great job, but guys not every body is computer programmer!
    I mean when you compiled a new version for a different platform wouldn’t be nice to upload it somewhere to help others?
    I would be very thankful if Sam point the Mac version to me, or send it to my email.
    Thanks

  • Dave

    I think the idea is pretty nice, but I can not use it because it doesn’t support SSL.

    Are there any plans to support SSL? Or is that too difficult?

  • Muxx

    Hello guys,

    I’ve also tried the proxy, but sometimes login fails and if it works, the folder only shows 1 Mail (each folder the same…) Is this problem known?

    Greetings
    Muxx

  • Muxx

    BIG BIG Thanks, it works like a charm!!! First tried the java-version, but it only shows one mail-header and no content – the .c version works perfektly! Now I finaly have the same mails on my pcs without must use the web-interface. THX!!!

  • Muxx

    Oh, one important question left:

    If I send an email, it couldn’t be saved into the “outbox” also drafts don’t work – what do I wrong? Moving mails work, deleting works, and all the other things seem also to work, but saving new mails don’t work :( The mails are correctly sent, but there is no copy in the folder…

    Would be verry nice, if you could help me with this problem.

    Greetings
    Muxx

  • Muxx

    Also “ALT + F2” do 😀 – just insert “./yahooproxy” and click ok, now the proxy runs in background :D

    Last thing is the “new mail problem” mentioned in an other comment 😉

  • Ameir Abdeldayem

    I’ve never had this problem but if you email me your log (remove your login info) I can try to help you further. It may be related to the OK/completed issue listed in the source.

  • Ameir Abdeldayem

    I’ll run some tests on this; Yahoo’s IMAP implementation isn’t very friendly and might limit write access.

  • Muxx

    I’m sry, it wasn’t your great proxy, but the java one – after switching to yours, nearly everything was fine 😀

  • Amir Emon

    Hi Ameir,

    This is really cool thanks for your help.. I am able to use the program but I am experiencing some problems with my Thunderbird 3.1.. I’m using Windows 7 32bit..
    everytime I moved from one folder to another it ask for my password or to try a new password.. I have checked the box to remember my password but It seems like it’s coming on and on if I’ll check my email or if I have to switch folders.. And also odes the command prompt window needs to be open always?

    Thanks! You’re really great..

  • Dave

    Hello,

    Yahooproxy0.3 worked for me on the first try for reading e-mail and moving e-mails among folders in my yahoo account (to which I am migrating from wretched hotmail). I am using outlook 2003 client.

    Only known problem for me – I am not yet successful to send e-mail using the yahoo account and outlook 2003 client.

    My settings right now are:

    outgoing mail server: smtp.mail.yahoo.com
    my outgoing server requires authentication: (checked)
    use same settings as my incoming mail server: (checked)
    outgoing server (SMTP) port: 25
    this server requires an encrypted connection (SSL): (checked)

    Is this correct from your experience?

    Thank you very much!

  • Ameir Abdeldayem

    If you’re using SSL, you should be on port 465. Try that, and if it doesn’t work, undo SSL and use port 25. Do one or the other, although the former is more secure. Let me know how it goes.

  • Ameir Abdeldayem

    Hi Amir, nice name :)
    The Yahoo IMAP server doesn’t like switching between folders fast, nor having webmail and IMAP open at the same time. Give it a second to switch between folders and make sure webmail is closed. Other than that, I’m not too sure what the issue could be; I’m able to navigate things fine on my end. Let me know what happens.
    As far as hiding the command prompt, that can easily be done with something like AutoIT. If interest is strong enough, I’ll make it happen. Keep your eyes peeled :)

  • Linton

    Hi guys,

    Can someone post clear instructions on how to enable this for use will MAC mail?

    how do i ‘point’ mail to look for the proxy?

    cheers

    Linton

  • Joe

    Hey! I came across your GREAT Yahoo IMAP proxy, and it works like a charm. Only bugs I can see [and it may be because of Yahoo itself and not your proxy]:

    1. My client times out often with error “idle too long” if I leave my client open with Yahoo account active.

    2. While I can move files OUT of my yahoo account to local folders, and move items between folders on the Yahoo account, I cannot take an item from my local folders and drag it IN to the Yahoo account. I am most concerned with moving items SENT from my mail client to my SENT folder on Yahoo.

    Any suggestions would be appreciated!

  • guy

    I keep getting tis error on windows live mail:

    The connection to the server failed:
    Your IMAP command could not be sent to the server, due to non-network errors. This could, for example, indicate a lack of memory on your system.

    Configuration:
    Account: Yahoo.com
    Server: localhost
    User name: lachelmelon
    Protocol: IMAP
    Port: 993
    Secure(SSL): 1
    Code: 800ccc0e

  • Joe

    Hi -

    As Windows Live is attempting to access the account, what do you see in the command window for the proxy?

    Try setting the server name to 127.0.0.1 [should work with localhost too, but you never know].

    I have it working fine with Windows Live Mail, aside from the bugs I listed above (it won’t handle moves between local and IMAP folders and has a short idle limit). If you e-mail me at [b]JOE AT RUGGIEROAV DOT NET[/b], I can let you test it with an instance I have running on a remote server.

  • Ameir Abdeldayem

    Your username should be your full Yahoo email address, and you should disable SSL. Also, your port should be 3490. The IMAP proxy will connect to the proper port (143) for you.

  • Angel Blue01

    Hello and thanks for this program. I’ve gotten Thunderbird 3.0 to work with it in Windows without any trouble.

    However, I mostly use Linux that has been having problems. I use openSUSE 11.2 and KDE SC 4.5. I compiled the program without any trouble but the mail checker plasmoid doesn’t seem to work with it. In the Konsole window running yahooproxy I get the following output:

    [quote]
    server: waiting for connections…
    server: got connection from 127.0.0.1
    Connected to imap.mail.yahoo.com
    [Chunk 1]: message length = 201 201
    [imap.mail.yahoo.com]: * OK [CAPABILITY IMAP4rev1 ID NAMESPACE X-ACL-ID AUTH=PLAIN AUTH=LOGIN AUTH=XYMCOOKIE AUTH=XYMECOOKIE AUTH=XYMCOOKIEB64 AUTH=XYMPKI STARTTLS] IMAP4rev1 ymail_nginx-0.7.65_9 imap427.mail.ac4.yahoo.com

    out of loop
    [127.0.0.1]: 001 LOGIN [email protected] mypassword

    [Chunk 1]: message length = 71 71
    [imap.mail.yahoo.com]: 001 NO [AUTHORIZATIONFAILED] Access to this service is not permitted.

    [/quote]

    Thanks!

  • Picses

    WOW!!!!

    I had been literally wasting my time in order to get yahoo mail free in Opera Mail Client.
    I could not even guess that it would be this simple!!!

    Thanx a bunch.

  • Vlad S

    hi,
    can you please offer us an in depth tutorial on how to set up this proxy under ubuntu and how to configure thunderbird 3 for the unexperienced in the land of computing.
    thank you