+1 vote

When I try to connect to
pop3.Connect("pop.gmail.com",995);
I got this error,
Limilabs.Client.ServerException
HResult=0x80131500
Message=Tried to read a line. No data received. Please make sure that antivirus and firewall software are disabled or configured correctly.
Source=Mail
StackTrace:
at   . ()
at Limilabs.Client.POP3.Pop3Response. (Stream stream)
at Limilabs.Client.POP3.Pop3. ​(Boolean multiline)
at Limilabs.Client.POP3.Pop3.GetServerGreeting()
at Limilabs.Client.ClientBase.Connect(String host, Int32 port, Boolean useSSL)
at PrimeAPI.Controllers.MailController.RecieveMailPOP3() in S:\Sinju\PrimeApplication\PrimeAPI\PrimeAPI\Controllers\MailController.cs:line 62
at Microsoft.Extensions.Internal.ObjectMethodExecutor.<>cDisplayClass33_0.b0(Object target, Object[] parameters)
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.VoidResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__12.MoveNext()

Inner Exception 1:
Exception: Tried to read a line. No data received.

Please help me

by

1 Answer

0 votes

Port 995 is for SSL/TLS connections.

Use Pop3.ConnectSSL method instead of Pop3.Connect.

Please also not that as this is a standard POP3 port, there is no need to specify it at all:

using(Pop3 pop3 = new Pop3())
{
    pop3.ConnectSSL("pop.gmail.com");   // <-- Use SSL/TLS on 995

    pop3.UseBestLogin("user", "password");

    List<string> uids = pop3.GetAll();
    foreach (string uid in uids)
    {
        var eml = pop3.GetMessageByUID(uid);
        IMail email = new MailBuilder().CreateFromEml(eml);

        string subject = email.Subject;
    }
    pop3.Close();
}  

If you plan to use POP3 with Gmail those 2 articles may help:

https://www.limilabs.com/blog/enable-pop3-in-gmail

https://www.limilabs.com/blog/gmail-pop3-behavior

If you want to have a greater control over your emails you may want to switch to IMAP protocol.

by (297k points)
edited by
...