发送电子邮件时发生错误 [英] eror occure during email sending

查看:129
本文介绍了发送电子邮件时发生错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用简单的邮件发送应用程序,但是在发送邮件期间发生以下错误

SMTP服务器需要安全连接,或者客户端未通过身份验证.服务器响应为:5.5.1需要身份验证.
我使用windoes7和asp.net(c#).

请帮助我.

i use the simple mail sending application but the following error occure during sending the mail

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.
i use windoes7 and asp.net(c#).

plz help me.

推荐答案

尝试使用类似的讨论来链接:
http://forums.asp.net/p/1327338/3667481.aspx [ ^ ]
http://stackoverflow. com/questions/6477055/the-smtp-server-requires-a-secure-connection-or-the-client-was-not-authenticated [ SMTP服务器需要安全连接,否则客户端不需要已验证.服务器响应为:5.5.1需要身份验证. [
Try these links with similar discussions:
http://forums.asp.net/p/1327338/3667481.aspx[^]
http://stackoverflow.com/questions/6477055/the-smtp-server-requires-a-secure-connection-or-the-client-was-not-authenticated[^]
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.[^]


SmtpClient client = new SmtpClient();
        client.DeliveryMethod = SmtpDeliveryMethod.Network;
        client.EnableSsl = false;
        client.Host = "smtp.gmail.com";
        client.Port = 587;                 // setup Smtp authentication    
        System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("****@gmail.com", "******");
        client.UseDefaultCredentials = false;
        client.Credentials = credentials;
        MailMessage msg = new MailMessage();
        msg.From = new MailAddress("rma.maksat@gmail.com");
     
        msg.To.Add(new MailAddress("prateekfgiet@gmail.com"));
      
        msg.Subject = "New RMA No:'" + DropDownList1.SelectedValue.ToString() + "'";
        msg.IsBodyHtml = true;
        msg.Body = "Status is : '" + DropDownList3.SelectedValue.ToString() + "',      for the Request of RMA No:'" + DropDownList1.SelectedValue.ToString() + "'";
        client.Send(msg);


using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
using System.Net.Mail;

protected void Page_Load(object sender, EventArgs e)
   {

       String mailMsg = "Hello, "      
       objEmail.To.Add("email@yourdomain.com");
       objEmail.CC.Add("email@yourdomain.com");
       objEmail.From = new MailAddress("email@yourdomain.com", "Company Name");
       objEmail.Subject = "Text mail";
       objEmail.Body = mailMsg;
       objEmail.IsBodyHtml = true;
       objEmail.Priority = MailPriority.High;
       SmtpClient smtp1 = new SmtpClient();
       smtp1.Host = "relay-hosting.secureserver.net";
       smtp1.UseDefaultCredentials = false;
       smtp1.EnableSsl = false;
       try
       {
           smtp1.Send(objEmail);
           objEmail.Dispose();
           objEmail = null;

       }
       catch (Exception exc)
       {
           
           string msg = exc.Message;
           
       }
}


这篇关于发送电子邮件时发生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆