服务器不支持安全连接。 [英] Server does not support secure connections.
本文介绍了服务器不支持安全连接。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从Asp.net页面发送电子邮件时收到错误服务器不支持安全连接。
我的代码是
Hi,
I am getting an Error while sending Email from Asp.net page "Server does not support secure connections".
my code is
{
string from = "frommail";
string to ="tomail";
string Password = "password";
int port = Convert.ToInt32(ConfigurationManager.AppSettings["port"]);
string smtp = Convert.ToString(ConfigurationManager.AppSettings["smtp"]);
string Subject ="Enquiry";
string body ="Sender Name :"+txtname.Text+"\n"+
"Phone :"+txtphone.Text+"\n"+
"Email :"+txtemail.Text+"\n"+
"Address :"+txtaddress.Text+"\n"
+"Enquiry :"+txtenquiry.Text;
MailMessage Msg = new MailMessage(from, to, Subject, body);
//Smtp Host is the name or Ip host of the computer used for sending mail
SmtpClient smtpobj = new SmtpClient("smtp.rediffmailpro.com",587);
smtpobj.Host = "smtp.rediffmailpro.com";
smtpobj.Port =587;
smtpobj.EnableSsl = true;
smtpobj.UseDefaultCredentials = true;
smtpobj.Credentials = new System.Net.NetworkCredential(from,Password);
try
{
smtpobj.Send(Msg);
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "ASET", "<script type='text/javascript'>alert('Your Message Has Been Send ');</script>", false);
CleaContents();
}
catch (Exception ex)
{
lbltext.Text = ex.Message;
}
}
------------- --------
同时给gmail邮件id和gmail smtp它的工作但是当使用rediffmail和smtp时它获取的信息就像服务器没有支持安全连接。
推荐答案
尝试将端口号更改为25而不是587。 587用于gmail帐户,rediffmail用于25.另外,检查smtpobj.UseDefaultCredentials值,如果是安全连接,则需要将其设置为false并提供与该帐户关联的用户名和密码。
参考
http://enlook.wordpress.com/techs-and-tips- you-finding / mail-server-settings-for-hotmail-yahoo-mail-gmail-msn-aol-and-more / [ ^ ]
希望这有帮助......
Try changing the port number to 25 instead of 587 . 587 is for gmail account and rediffmail uses 25. Also , check the smtpobj.UseDefaultCredentials value, if its secure connection then you need to set it false and provide username and password associated with the account.
Refer
http://enlook.wordpress.com/techs-and-tips-you-finding/mail-server-settings-for-hotmail-yahoo-mail-gmail-msn-aol-and-more/[^]
Hope this helps...
smtpobj.EnableSsl = false
;
使用此
;
Use this one
这篇关于服务器不支持安全连接。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文