PDA

View Full Version : Giúp đỡ cách cấu hình để gửi mail C#



longtqdayma
11-05-2010, 09:37
Mình có đoạn code gửi mail

System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
mail.From = new System.Net.Mail.MailAddress(txtfrom.Text.Trim());
mail.To.Add(new System.Net.Mail.MailAddress(txtto.Text.Trim()));
mail.Subject = txtSubject.Text;
mail.Body = txtBody.Text.Trim();

System.Net.Mail.SmtpClient smtpmail = new System.Net.Mail.SmtpClient("127.0.0.1",8080);
smtpmail.Send(mail);

nhưng khi thực hiện gửi nó báo lỗi
"No connection could be made because the target machine actively refused it 127.0.0.1:8080"

nếu để smtp là :smtp.gmail.com và port của google thì vẫn có lỗi
mình không biết làm thế nào

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 216.239.44.95:25

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 216.239.44.95:465