Tag: smtp

SMTP服务器需要安全连接或客户端未经过身份validation – 仍然无法正常工作

我收到了上述错误。 我看过在线解决方案,我似乎已经做了所有必要但我仍然得到它。 我已经包含了Enablessl = true; 交付方式是网络,我提供了凭据。 我调试了它,用户名和密码似乎是正确的。 using System; using System.Net; using System.Net.Mail; using System.Windows.Forms; namespace SendMail { public partial class MainWindow : Form { #region Private variables private MailMessage _message = new MailMessage(); private EmailSender sender = EmailSender.GetInstance(); private SmtpClient _smtpClient = new SmtpClient(); #endregion public MainWindow() { InitializeComponent(); } private void PrepareMailMessage() { […]

C#app中的SMTP客户端发送错误

嘿,伙计们,我正在尝试使用hotmail帐户设置电子邮件发送应用程序。 代码如下所示: MailMessage mail = new MailMessage(from, to); mail.Subject = “Proba email”; mail.Attachments.Add(new Attachment(“C:\\Documents and Settings\\Proba.txt”)); SmtpClient client = new SmtpClient(); client.UseDefaultCredentials = false; client.Port = 587; // 465 568 client.Host = “smtp.live.com”; client.EnableSsl = true; client.Credentials = new System.Net.NetworkCredential(“smg@hotmail.com”, “password”); client.SendCompleted += new SendCompletedEventHandler(client_SendCompleted); client.SendAsync(mail, “token”); 使用,Async我实际上没有错误,我甚至得到反馈说消息发送(事件触发器)但消息永远不会到来。 如果我使用简单的client.Send void,我收到以下错误: 5.3.4未采取的请求行动; 要继续发送邮件,请登录您的帐户。 那么关于问题可能是什么的任何想法? 当我试图传递hotmail的SMTP设置时,我得到了各种设置,说端口25,然后是587所以也许它就是那里的东西。 非常感谢任何帮助! […]

尝试通过SMTP发送邮件。 没有邮件到达,没有exception错误

问题:制作了一个小型邮件程序,它在我的开发者电脑上完美运行,但投入生产后却失败了。 protected void Page_Load(object sender, EventArgs e) { string smtpHost = ConfigurationManager.AppSettings[“SmtpAddress”]; MailMessage mail = new MailMessage(); mail.From = new MailAddress(ConfigurationManager.AppSettings[“FromMailAddress”]); mail.Sender = new MailAddress(ConfigurationManager.AppSettings[“FromMailAddress”]); mail.To.Add(new MailAddress(“zzz@xxx.yy”)); mail.Subject = “Test mail”; mail.Body = string.Format(“Is this mail sent via {0} ?”, smtpHost); lblMsg2.Text = string.Format(“SmtpHost: {0}”, smtpHost); ; SmtpClient client = new SmtpClient(smtpHost); try { client.Send(mail); […]

我如何排序“ping”SMTP服务器,以便检查帐户/密码是否有效?

我正在尝试构建一个小的WPF电子邮件发件人教程,但如果它有这个明显的错误我不想分享它。 目前,这就是发生的事情。 用户输入用户名和密码。 标签’loginstatus’更改为“已登录”,无论它是否是粗略的。 消息正文和发送到字段已启用。 用户按下“发送”按钮,如果有exception(例如,用户名/密码错误),则消息框会显示该消息,并且loginstatus会更改回注销状态。 这是非常错误的,我想解决它。 我怎样才能“ping”以查看凭证是否正确(不发送测试电子邮件)。 我正在使用smtp.gmail.com端口587 编辑这是我发送电子邮件的方式。 var client = new SmtpClient(“smtp.gmail.com”, 587) { Credentials = new NetworkCredential(username, password), EnableSsl = true }; try { client.Send(fromEmail, toEmail, subject, body); } catch (Exception e) { MessageBox.Show(e.Message); }

C#使用附件发送电子邮件(图像)

我的方法使用SMTP中继服务器发送电子邮件。 一切正常(电子邮件被发送), 除了附件(图像)以某种方式压缩/记录,并且无法从电子邮件中检索。 该方法如下所示: public static bool SendEmail(HttpPostedFileBase uploadedImage) { try { var message = new MailMessage() //To/From address { Subject = “This is subject.” Body = “This is text.” }; if (uploadedImage != null && uploadedImage.ContentLength > 0) { System.Net.Mail.Attachment attachment; attachment = new System.Net.Mail.Attachment(uploadedImage.InputStream, uploadedImage.FileName); message.Attachments.Add(attachment); } message.IsBodyHtml = true; var smtpClient = […]

发送到多个电子邮件地址但只显示一个C#

我在C#中使用SmtpClient,我将发送潜在的100多个电子邮件地址。 我不想遍历每一个并向他们发送个人电子邮件。 我知道可以只发送一次消息,但我不希望来自地址的电子邮件显示100个其他电子邮件地址,如下所示: Bob Hope; Brain Cant; Roger Rabbit;Etc Etc 是否可以发送一次消息并确保只有收件人的电子邮件地址显示在电子邮件的部分?

SocketException:没有这样的主机是已知的 – 无法发送电子邮件 – 统一

public void EmailSending() { MailMessage mail = new MailMessage(); mail.From = new MailAddress(“xxx@gmail.com”); mail.To.Add(“xxx@gmail.com”); mail.Subject = “Test Mail”; mail.Body = “This is for testing SMTP mail from GMAIL”; SmtpClient smtpServer = new SmtpClient(“smtp.gmail.com”); smtpServer.Port = 587; smtpServer.Credentials = new System.Net.NetworkCredential(“xxx@gmail.com”, “pw”) as ICredentialsByHost; smtpServer.EnableSsl = true; ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors […]

在Office365上使用默认SMTP凭据的例外 – 客户端未经过身份validation,无法在MAIL FROM期间发送匿名邮件

我正在使用NLog将日志作为带有自定义邮件目标的电子邮件发送。 我从我的office365帐户发送设置为我的web.config(我的主项目)中的默认设置,如下所示: 我用我的日志目标(在我的NLog实现包中)覆盖Write方法,如下所示: protected override void Write(LogEventInfo logEvent) { try { using (var mail = new MailMessage()) { this.SetupMailMessage(mail, logEvent, this.Layout.Render(logEvent)); using (SmtpClient smtpClient = new SmtpClient()) { smtpClient.UseDefaultCredentials = true; smtpClient.Send(mail); } } } catch (Exception exception) { throw new NLogRuntimeException(“An error occurred when sending a log mail message.”, exception); } } 当系统尝试从此帐户发送邮件时,将引发以下System.Net.Mail.SmtpException : […]

5.7.0必须首先发出STARTTLS命令

我正在尝试通过C#发送电子邮件。 虽然我相信我做的一切都是正确的,但它仍然会抛出这个exception: “SMTP服务器需要安全连接或客户端未经过身份validation。服务器响应为:5.5.1需要身份validation。了解详情” 起初我想,它可能是一个区域/ IP /区域问题……但是当我登录gmail时,没有任何警告。 可以肯定的是,我已经将文件上传到网站以便从那里进行检查,但仍然会出现错误。 比我尝试将端口更改为465.它也没有用。 我首先尝试使用由Google Apps帐户管理的帐户。 所以我认为可能是它,但它不是…… 我现在真的没有想法。 你们中有谁有想法? 这是示例代码: SmtpClient sm = new SmtpClient(“smtp.gmail.com”,587); sm.Credentials = new NetworkCredential(“blabla@gmail.com”,”**”); sm.UseDefaultCredentials = false; sm.EnableSsl = true; sm.DeliveryMethod = SmtpDeliveryMethod.Network; sm.Send(“blabla@gmail.com”,”blabla2@tr3reklam.com”,”Test”,”Test”); **注意**我已经检查了帐户名和密码,它们都是正确的。

为什么我不能用c#连续发两封邮件?

我使用smtpClient使用c#发送电子邮件。 我必须每天发送大约100个不同的电子邮件,因为电子邮件根据收件人的不同而不能使用相同的邮件(添加几个收件人)。 我没有使用本地SMTP服务器,我理解(根据这里的 @rizzle响应),有一段时间必须留在一封邮件和另一封邮件之间。 但是,我正在睡觉我的程序10秒钟,它仍然是第一封被发送的电子邮件,而不是第二封电子邮件(到目前为止,我正在尝试使用两封电子邮件而不是一百封电子邮件)。 这是我的代码,任何想法? foreach (Person p in clientList) { AlternateView plainView = AlternateView.CreateAlternateViewFromString(“Texto visible para clientes que no tienen HTML”, null, “text/plain”); //AlternateView htmlView = AlternateView.CreateAlternateViewFromString(“Here is an embedded image.”, null, “text/html”); string htmlString = “html string body of the email”; AlternateView htmlView = AlternateView.CreateAlternateViewFromString(htmlString, null, “text/html”); System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(); […]