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工作正常,但服务器没有工作。我该如何解决这个错误? 我尝试了一切..我的主机是1und1。