【发布时间】:2023-03-31 04:13:01
【问题描述】:
private void MailGonder(string to, string from, string password, string subject, string body, HttpPostedFile ektekidosya)
{
using (MailMessage mm = new MailMessage(from, to))
{
mm.Subject = subject;
mm.Body = body;
mm.IsBodyHtml = false;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
NetworkCredential NetworkCred = new NetworkCredential(from, password);
smtp.UseDefaultCredentials = false;
smtp.Credentials = NetworkCred;
smtp.Port = 587;
smtp.Send(mm);
}
}
protected void BtnGonder_Click(object sender, EventArgs e)
{
string to = txtKime.Text;
string from = txtEmail.Text;
string password = txtPassword.Text;
string subject = txtKonu.Text;
string body = txtMesaj.Text;
HttpPostedFile ektekidosya = fuAttach.PostedFile;
try
{
MailGonder(to, from, password, subject, body, ektekidosya);
Response.Write("Mail başarıyla gönderildi");
}
catch (Exception ex)
{
Response.Write("Mail gönderiminde hata oluştu. Err: " + ex.ToString());
}
}
我尝试了不同的端口,但没有任何帮助,我不断收到错误消息。Localserver 工作正常,但 Server 没有工作。我该如何解决这个错误? 我什么都试过了。我的主机是 1und1。
【问题讨论】:
-
之前是否有效?