服务器拒绝了发件人地址。服务器响应是:需要530认证 [英] The server rejected the sender address. The server response was: 530 authentication needed

查看:156
本文介绍了服务器拒绝了发件人地址。服务器响应是:需要530认证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,



在default.aspx文件中运行下面提到的代码时,它会成功执行。虽然添加在单独的类文件中,但它会将错误抛出为 服务器拒绝了发件人地址。服务器响应是:需要530验证



Dear All,

While runing the below mentioned code in default.aspx file it executes successfully. while added in the seperate class file it throws the error as "The server rejected the sender address. The server response was: 530 authentication needed"

private void MailSend_prop(string msg, string toAddress, string psubject)
{
        try
        {
            System.Web.Mail.MailMessage msg1 = new System.Web.Mail.MailMessage();

            msg1.From =ConfigurationManager.AppSettings["MailFromAdd"].ToString();
            msg1.To = toAddress;
            msg1.Subject = psubject;
            msg1.Priority = System.Web.Mail.MailPriority.High;
            msg1.BodyFormat = System.Web.Mail.MailFormat.Html;
            string bodystring = string.Empty;
            bodystring += msg;


            msg1.Body = bodystring;

            msg1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
            msg1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", "2");
            msg1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", ConfigurationManager.AppSettings["MailServer"].ToString());
            msg1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "25");
            msg1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", msg1.From);
            msg1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", ConfigurationManager.AppSettings["MailFromAddPwd"].ToString());

            System.Web.Mail.SmtpMail.SmtpServer = ConfigurationManager.AppSettings["MailServer"].ToString();


            System.Web.Mail.SmtpMail.Send(msg1);

        }
        catch (Exception ex)
        {
            throw ex;
        }

}



问候,

G Mariappan。


Regards,
G Mariappan.

推荐答案

上面的代码工作正常,但是该类是另一个项目文件而没有构建该项目文件,它将不会接受代码的更改。这就是问题。



现在问题很好。



问候,

G Mariappan
Above code is working fine but the class is another project file without building that project file,it will wont accept the changes of the code.That's the problem.

Now problem is finshed.

Regards,
G Mariappan


这篇关于服务器拒绝了发件人地址。服务器响应是:需要530认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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