我在我的软件中使用WebMail。我想从我的雅虎商业帐户发送电子邮件。当我使用一般雅虎帐户然后它工作正常。但是,当我尝试从我的雅虎商业帐户发送电子邮件时,电子邮件没有收到发送。
WebMail.SmtpServer = "smtp.bizmail.yahoo.com";
WebMail.SmtpPort = 465;
WebMail.EnableSsl = true;
WebMail.UserName = "john.smith@mycompanyname.com";
WebMail.From = "john.smith@mycompanyname.com";
WebMail.Password ="*****123";
WebMail.Send(to:"abc123@gmail.com,xyz123@yahoo.com", subject: "CRM Request Testing", body: body, from: null, cc: "pqr123@hotmail.com", filesToAttach: null, isBodyHtml: true, additionalHeaders: null, bcc: "abcxyz@gmail.com", contentEncoding: null, headerEncoding: null, priority: null, replyTo: null);
return RedirectToAction("EmailSend");
但不知怎的,它不起作用。
错误:
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 System.Web.Helpers.WebMail.Send(String to, String subject, String body, String from, String cc, IEnumerable`1 filesToAttach, Boolean isBodyHtml, IEnumerable`1 additionalHeaders) at EmailExample.Controllers.HomeController.Feedback(String email, String subject, String body) in C:\Users\Lenovo\Documents\Visual Studio 2010\Projects\EmailExample\EmailExample\Controllers\HomeController.cs:line 45