简体   繁体   English

System.Net.Mail.SmtpException:发送邮件失败。 无法从传输连接中读取数据

[英]System.Net.Mail.SmtpException: Failure sending mail. Unable to read data from the transport connection

This is the relevant code (C#) 这是相关的代码(C#)

                    MailMessage m;
                    SmtpClient client;   

                    client.Host = "smtp.mail.yahoo.com";
                    client.Port = 465;  
                    client.EnableSsl = true;
                    client.Credentials = new NetworkCredential("mymail@yahoo.com", "mypassword");

                    m = new MailMessage();
                    m.From = new MailAddress("mymail@yahoo.com");
                    m.To.Add(new MailAddress("anothermail@gmail.com"));
                    m.Subject = "My subject";
                    m.Body = "This is my body. ";

                    client.Send(m);

This is the full error trace 这是完整的错误跟踪

System.Net.Mail.SmtpException: Failure sending mail. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.DelegatedStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at System.Net.BufferedReadStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine)
   at System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller)
   at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)
   at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)
   at System.Net.Mail.SmtpClient.GetConnection()
   at System.Net.Mail.SmtpClient.Send(MailMessage message)
   --- End of inner exception stack trace ---
   at System.Net.Mail.SmtpClient.Send(MailMessage message)
   at EmailSender.EmailSenderForm.send() in c:\Users\Ankur\Documents\Visual Studio 2012\Projects\EmailSender\EmailSender\EmailSenderForm.cs:line 91

What am I doing wrong here? 我在这里做错了什么?

As far as I know, Yahoo doesn't allow 3rd party mail clients to operate their accounts. 据我所知,雅虎不允许第三方邮件客户端操作其帐户。 That's why you need webmail extensions with Thunderbird for example. 这就是为什么您需要使用Thunderbird进行webmail扩展的原因。 Yahoo offers their Yahoo Mail Plus for these kind of services. 雅虎为其此类服务提供Yahoo Mail Plus。 Can you try your application with another mail account in Gmail? 您可以使用Gmail中的另一个邮件帐户尝试您的应用程序吗? There it should work fine. 在那里应该可以正常工作。

I have this code configured for an outlook account for sending emails. 我为一个用于发送电子邮件的Outlook帐户配置了此代码。 I have it working two years now without any modifications. 我已经工作两年了,没有任何修改。 It should work out of the box (just changing the account names): 它应该开箱即用(只需更改帐户名):

MailMessage mm = new MailMessage(@"example@hotmail.com",
                     dest, textBox1.Text, richTextBox1.Text);
SmtpClient client = new SmtpClient("smtp.live.com", 587);
client.Credentials = new NetworkCredential(@"examplehotmail.com", "password");
client.EnableSsl = true;
messageSent = false;
client.SendAsync(mm, null);
client.SendCompleted += SentMessageTrigger;

I hope it helps. 希望对您有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 System.Net.Mail.SmtpException:发送邮件失败。 无法建立连接,因为目标计算机主动拒绝它127.0.0.1:25 - System.Net.Mail.SmtpException: Failure sending mail. No connection could be made because the target machine actively refused it 127.0.0.1:25 邮件发送失败。 ---> System.IO.IOException:无法从传输连接读取数据:net_io_connectionclose - Failure sending mail. ---> System.IO.IOException: Unable to read data from the transport connection: net_io_connectionclose c#smtpException:发送邮件失败-无法从传输连接读取数据:net_io_connectionclosed - c# smtpException: Failure sending mail - Unable to read data from the transport connection: net_io_connectionclosed smtp.office365.com 发送邮件失败。 无法从传输连接读取数据:net_io_connectionclosed - smtp.office365.com Failure sending mail. Unable to read data from the transport connection: net_io_connectionclosed System.Net.Mail.SmtpException {“发送电子邮件失败。”} - System.Net.Mail.SmtpException {“Failure Sending Email.”} 将白名单IP gmail smtp-System.Net.Mail.SmtpException:发送邮件失败 - Whitelist IP gmail smtp - System.Net.Mail.SmtpException: Failure sending mail system.net.mail.smtpException:无法连接到远程服务器? - system.net.mail.smtpException :Unable to connect to the remote server? 出现错误:-System.net.mail.SmtpException - Getting error:-System.net.mail.SmtpException System.Net.Mail.SmtpException:邮箱不可用 - System.Net.Mail.SmtpException: Mailbox unavailable SmtpException: 发送邮件失败。 循环发送附件 - SmtpException: Failure sending mail. Loop sending with Attachments
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM