SMTP服务器异常 [英] SMTP Server Exception
本文介绍了SMTP服务器异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下是我的代码:-
Following is my code:-
string to, sub, mess;
to = "info@sdmmedicalcollege.org";
sub ="Weekly Clinical Quiz";
mess ="Quiz Title: " + dr["Quiz_Title"].ToString() + "<br>Name: " + txtName.Text + "<br> Email: " + txtEmail.Text + "<br>Clinical Diagnosis: " + txtContent.Text;
mess = mess + "<br> Occupation : " + txtOccupation.Text + "<br>Institution: " + txtInst.Text;
// tel = "99";
//MailMessage mg = new MailMessage();
//MailMessage mg = new MailMessage(txtEmail.Text, "info@sdmmedicalcollege.org");
MailMessage mg = new MailMessage(txtEmail.Text, dr["Quiz_Email"].ToString());
mg.Subject = sub;
mg.Body = mess;
mg.IsBodyHtml = true;
SmtpClient st = new SmtpClient();
st.EnableSsl = true;
st.Host = "smtp.secureserver.net";
st.Port = 25;
st.Credentials = new System.Net.NetworkCredential("info@sdmmedicalcollege.org", "hospital");
st.UseDefaultCredentials = true;
st.DeliveryMethod = SmtpDeliveryMethod.Network;
st.Send(mg);
尝试在服务器上运行此程序时,出现以下异常,
When am trying to run this on server,am getting following exception,
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. ua5sm10078511igb.10
我尝试使用不同的端口号(例如457,565),但对我来说不起作用.
谁能帮我吗?
I tried with the different port numbers like 457,565 but it didnt work out for me.
Can anyone please help me??
推荐答案
使用st.UseDefaultCredentials = true;
st.Credentials
将被忽略,并且将使用当前登录的用户凭据.
如果您明确指定凭据,请保留UseDefaultCredential = false
http://msdn.microsoft.com/en-us/library/system. net.mail.smtpclient.usedefaultcredentials [ ^ ]
When you usest.UseDefaultCredentials = true;
st.Credentials
will be ignored and currently logged on user credentials will be used.
If you specify Credentials explicitly, leave UseDefaultCredential = false
http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.usedefaultcredentials[^]
检查此链接
使用ASP.NET 2.0的简易SMTP邮件 [ ^ ]
Check this link
Easy SMTP Mail Using ASP.NET 2.0[^]
这篇关于SMTP服务器异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文