Connection closed by server when trying connect to gmail

0 votes
asked Mar 24, 2010 by Yarik (160 points)
edited Mar 23, 2011

This is your example code. How to connect to gmail.

private void DoMethod ()
    {
        bool connecting = false;
        Exception error;
        try
        {
            if (_pop.State == Pop3State.Disconnected)
            {
                connecting = true;

                // Get configuration.
                string server = _config.GetString("server");
                int port = _config.GetInt32("port");
                string userName = _config.GetString("userName");
                string password = _config.GetString("password");

                SetStatus(string.Format("Connecting to {0}...", server));

                // Forget the old message list.
                _messageList = null;

                // Connect to the server.
                _pop.Connect(server, port);
                _pop.Login(userName, password);

                connecting = false;
            }

            // Run desired background operation.
            _method ();

            error = null;
        }
        catch (Exception x)
        {

            Pop3Exception px = x as Pop3Exception;
            if (px != null && px.Status == Pop3ExceptionStatus.OperationAborted)
            {
                // If the operation is a result of an abort, don't report it as error.
                error = null;
                _pop.Disconnect();
            }
            else
            {
                error = x;

                // If this is a failed connection attempt, disconnect.
                if (connecting)
                    _pop.Disconnect();
            }
        }
        finally
        {
            _thread = null;
        }

        // Resets status bar and informs the main form that the operation finished.
        SetStatus("");
        if (_callback != null)
            _owner.SafeInvoke(_callback, new object[] {error});
    }

when i tried to connect with trial version of Rebex mail i do this succeed with this code:

// connect and log in Pop3 client = new Pop3(); client.Connect("pop.gmail.com", 995, null, Pop3Security.Implicit); client.Login(email, password);

// process messagess...

// logount and disconnect client.Disconnect();

after i purchased the normal version. i don't have this method: client.Connect("pop.gmail.com", 995, null, Pop3Security.Implicit);

i have only this: // Connect to the server. _pop.Connect(server, port);

and i think that gmail need secure connection.

please help me connect to gmail.

Applies to: Rebex Secure Mail

1 Answer

0 votes
answered Mar 25, 2010 by Martin Vobr (12,940 points)
edited Mar 25, 2010

Gmail does not allow unsecured connection. You have to call following method to connect:

client.Connect("pop.gmail.com", 995, null, Pop3Security.Implicit);

It looks like you purchased the version which is not capable of doing so. E.g. if you ordered the Rebex POP3 you have to upgrade to Rebex Secure POP3.

Could you please send me your order number or email used for order to support@rebex.net so I'm able to send you the upgrade link?

If the order is not older than 90 days you can upgrade and pay only the price difference. If the order is older you'll still get an upgrade discount. For details see http://www.rebex.net/shop/upgrade.aspx

...