0

HigLaboでメールクライアントを作成していますまた、http プロキシを使用する必要があります。しかし、認証は毎回失敗します。私はここで基本コードを見つけました: .net pop3 over http proxy

これが私のコードです:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HigLabo.Net;
using HigLabo.Net.Pop3;
using System.Net.Sockets;
using System.Threading;

namespace ConsoleApplication1
{
    class Program
    {
        static Pop3Client pop;
        static Socket socket;

    static void Main(string[] args)
    {
        String proxyAddr = "112.241.212.104"; //This seemed to be working
        int proxyPort = 8585;
        byte[] buffer = new byte[25];

        pop = new Pop3Client("PopClient");
        socket = new Socket(AddressFamily.InterNetwork,
                                     SocketType.Stream,
                                     ProtocolType.Tcp);

        Console.WriteLine("Connecting to proxy...");
        socket.Connect(proxyAddr, proxyPort);
        Console.WriteLine("Connected to proxy");

        Console.WriteLine("Sending Packets...");
        socket.Send(Encoding.UTF8.GetBytes("CONNECT pop.mail.yahoo.com:995 HTTP/1.1<CR><LF>"));
        socket.Send(Encoding.UTF8.GetBytes("<CR><LF>"));
        Console.WriteLine("Packets sent");

        Console.WriteLine("Waiting for response...");
        socket.Receive(buffer);
        Console.WriteLine("Packets received");
        Console.WriteLine("Time Elapsed : " + timeElapsed + " seconds");

        Console.WriteLine("Connectong POP to socket...");
        if (pop.Connect(socket)) 
        {
            pop.Connect();
            Console.WriteLine("Connection completed");
        }
        else
        {
            Console.WriteLine("Disconnected");
            Disconnect();
            return;
        }

        pop.Ssl = true;
        pop.UserName = "EMAIL_ADDRESS";
        pop.Password = "PASSWORD";
        pop.ServerName = "pop.gmail.com";
        pop.Port = 995;

        Console.WriteLine("Authenticating...");
        if (pop.Authenticate())
        {
            Console.WriteLine("Authentication completed"); //Never comes here
            GetMail();
        }
        else
        {
            Console.WriteLine("Authentication failed"); //Always comes here
            Disconnect();
        }


    }

    private static void GetMail()
    {
        HigLabo.Mime.MailMessage msg = pop.GetMessage(1);
        Console.WriteLine(msg.BodyText);
    }

    static void Disconnect()
    {            
        Console.WriteLine("Disconnecting...");
        pop.Close();
        socket.Close();
        Console.WriteLine("Disconnected");
    }
}

}

アプリにも許可を与えました。ここで何が問題なのですか?

これを行うための他の/より良い/簡単な方法はありますか? 別のライブラリを使用している可能性がありますか?

4

1 に答える 1