Tag: smtp

ASP.net SMTP邮件通过代理

如何使用C#在ASP.net中设置SMTPClient以发送带有提供的代理地址的电子邮件? 或通过检测系统默认代理发送 我在web.config使用了以下代码但是没有用

使用smtpClient.send显示进度条

我正在使用此function通过Gmail发送邮件。 private bool uploadToGmail(string username, string password , string file , string backupnumber) { MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient(“smtp.gmail.com”); mail.From = new MailAddress(“jain@gmail.com”); mail.To.Add(“jain@gmail.com”); mail.Subject = “Backup mail- Dated- ” + DateTime.Now + ” part – ” + backupnumber; mail.Body = “Hi self. This mail contains \n backup number- ” […]

SMTP Gmail超时

不知道为什么会这样。 我搜索的每个地方都告诉我,我做得对。 但每次我尝试发送邮件时,它都会在smtpserver.Send(mail)上发送。发送smtpserver.Send(mail) private void emailReport(string email_address,int begDatabaseCount, int endDatabaseCount) { SmtpClient smtpserver = new SmtpClient(); MailMessage mail = new MailMessage(); smtpserver.EnableSsl = true; smtpserver.Port = 465; smtpserver.Host = “smtp.gmail.com”; smtpserver.Credentials = new NetworkCredential(“mtaylor@atr.com”, “password”); smtpserver.UseDefaultCredentials = false; mail = new MailMessage(); mail.From = new System.Net.Mail.MailAddress(“mtaylor@atr.com”, “ATR Reports”); mail.To.Add(email_address); mail.Subject = “FNAS Report – ” […]

.NET SMTP客户端 – 客户端无权作为此发件人发送

当我尝试通过ASP MVC3项目使用SmtpClient类发送电子邮件时,我的服务器上出现了奇怪的现象。 这是我正在使用的代码。 try { var client = new SmtpClient(“MailServer”); client.UseDefaultCredentials = true; MailMessage message = new MailMessage(“me@mydomain.com”, “friend@mydomain.com”, “Test Message”, “Test Body”); client.Send(message); } catch (Exception ex) { // Do Nothing } 我已经部署在三个环境中; 在Windows 7上(使用VS 2010 IIS)它发送电子邮件很好,在Windows 2003 IIS6机器上它发送电子邮件很好,最后在Windows 2008 R2 II7服务器上我收到以下错误: Mailbox unavailable. The server response was: 5.7.1 Client does not have permissions […]

Yahoo Mail的C#SMTP电子邮件发送代码失败但对其他服务器工作正常,有人可以帮忙吗?

我正在使用此代码通过yahoo SMTP服务器发送SMTP电子邮件,它是我正在编写的个人项目。 using System.Net.Mail; using System.Net; SmtpClient theClient = new SmtpClient(“smtp.mail.yahoo.com”, 465); theClient.UseDefaultCredentials = false; theClient.Credentials = new NetworkCredential(“username”, “password”); theClient.EnableSsl = true; MailMessage theMessage = new MailMessage(“username@yahoo.com”, “to.someone@gmail.com”); theMessage.Subject = “Dave test from C# subject”; theMessage.Body = “Dave test from C# body”; theClient.Send(theMessage); 它是用于发送SMTP电子邮件的非常标准的代码,但是…服务器似乎抛出错误。 它强行终止连接。 如果我使用其他SMTP服务器(如Gmail,Windows Live或其他各种ISP Smtp服务器),则不会发生这种情况。 这是exception和堆栈跟踪: System.IO.IOException: Unable to read data […]

尝试通过Office 365发送电子邮件时SMTP 5.7.57错误

我正在尝试设置一些代码以通过Office 365经过身份validation的SMTP服务发送电子邮件: var _mailServer = new SmtpClient(); _mailServer.UseDefaultCredentials = false; _mailServer.Credentials = new NetworkCredential(“test.user@mydomain.com”, “password”); _mailServer.Host = “smtp.office365.com”; _mailServer.TargetName = “STARTTLS/smtp.office365.com”; // same behaviour if this lien is removed _mailServer.Port = 587; _mailServer.EnableSsl = true; var eml = new MailMessage(); eml.Sender = new MailAddress(“test.user@mydomain.com”); eml.From = eml.Sender; eml.to = new MailAddress(“test.recipient@anotherdomain.com”); eml.Subject = “Test message”; […]

SecurityException:请求“System.Net.Mail.SmtpPermission”类型的权限

这是“在本地工作,在服务器上不起作用”的post之一。 我有一个发送电子邮件的简单联系表单。 在服务器上,我得到以下exception: Security Exception Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application’s trust level in the configuration file. Exception Details: System.Security.SecurityException: Request for the permission of type ‘System.Net.Mail.SmtpPermission, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’ […]

使用C#查找MX记录?

如何在C#中找到邮件服务器的MX记录?

使用localhost SMTP发送邮件

我正在尝试在IIS上设置SMTP服务器以发送邮件。 SMTP服务器旨在由C#中的ASP.NET代码使用。 我之前使用的是gmail smtp,其中我提供了smtp.gmail.com作为带有安全端口的主机和我的gmail uid / pwd。 这工作得很好。 这是用于执行此操作的代码。 SmtpClient smtpClient = new SmtpClient(); smtpClient.UseDefaultCredentials = false; smtpClient.Host = “smtp.gmail.com”; smtpClient.Port = 587; smtpClient.Credentials = new NetworkCredential(uname,pwd); smtpClient.EnableSsl = true; smtpClient.Send(mailMessage); 现在我打算在IIS上使用localhost SMTP服务器, 我应该为参数UseDefaultCredentials和Credentials提供什么值。 我将通过端口25向EnableSsl分配false。 此外,什么是最简单的SMTP虚拟服务器配置。

在.NET中捕获SMTP错误

通常情况下,我会发送这样的电子邮件: int statusCode = 0; string error = null; try { smtp.Send(mailMessage); statusCode = 250; } catch (SmtpFailedRecipientException e) { Log(String.Format(“[Exception] {0}\n\tSmtp: {1}{2}:{3}\n\tStatus Code: {4}\n\tFaild Recipient: {5}”, e.Message, smtp.Key, smtp.Value.Host, smtp.Value.Port, e.StatusCode, e.FailedRecipient)); statusCode = (int)e.StatusCode; error = e.Message; } catch (SmtpException e) { Log(String.Format(“[Exception] {0}\n\tSmtp: {1} – {2}:{3}\n\tStatus Code: {4}”, e.Message, smtp.Key, smtp.Value.Host, smtp.Value.Port, […]