首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Limilabs IMAP异常

Limilabs IMAP异常
EN

Stack Overflow用户
提问于 2014-10-20 00:58:20
回答 2查看 2.7K关注 0票数 4

我正在尝试使用Limilabs imap库连接电子邮件;

代码语言:javascript
复制
  tcpc = new System.Net.Sockets.TcpClient("imap.gmail.com", 993);

工作正常;而limilabs imap不能。

代码语言:javascript
复制
using (Imap imap = new Imap())
{
    imap.Connect("imap.gmail.com", 993);

给出异常:

代码语言:javascript
复制
Limilabs.Client.ServerException was unhandled
  HResult=-2146233088
  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   .(MemoryStream )
       at   .()
       at Limilabs.Client.IMAP.ImapResponse.(Stream )
       at Limilabs.Client.IMAP.Imap.(ImapResponse )
       at Limilabs.Client.IMAP.Imap.(String , Boolean )
       at Limilabs.Client.IMAP.Imap.ReceiveResponse(String tag)
       at Limilabs.Client.IMAP.Imap.wqf45mzzsju7786nbrb2h8aclqm8jmnx    ()
       at Limilabs.Client.ClientBase.Connect(String host, Int32 port, Boolean useSSL)
       at Limilabs.Client.ClientBase.Connect(String host, Int32 port)
       at ConsoleIMAP.Program.Main(String[] args) in c:\users\hmohamed\WcfServiceLibrary1\ConsoleIMP\Program.cs:line 136
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 
       HResult=-2146233088
       Message=Tried to read a line. No data received.
       Source=Mail
       StackTrace:
            at   .()
       InnerException: 
EN

回答 2

Stack Overflow用户

发布于 2015-02-04 14:13:00

Limilabs imap.Connect有一个重载来指定是否要使用SSL。它不会从您指定的端口推断它。您还可以使用imap.ConnectSSL方法。

有关更多信息,请参阅:http://www.limilabs.com/blog/use-ssl-with-imap

票数 2
EN

Stack Overflow用户

发布于 2017-01-30 20:25:23

我知道这个问题已经有2年的历史了,但对于其他有这个问题的人来说,这个问题可能很重要。

Imap.Connect/Imap.ConnectSSL方法不仅连接,它们还启动TLS/SSL协商(如果需要),接收初始服务器响应,并获得IMAP服务器支持的扩展。

这就是为什么使用TcpClient连接一开始看起来像是在工作,但实际上,您还没有启动TLS/SSL协商,也没有与服务器进行任何其他通信。

Gmail只支持TLS/SSL连接,必须使用ConnectSSL方式,也不需要显式指定端口:

代码语言:javascript
复制
using (Imap imap = new Imap())
{
    imap.ConnectSSL("imap.gmail.com");

    //...

    imap.Close()
}

请记住,您必须enable IMAP access for your account in Gmail

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26452999

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档