2009-10-31 66 views
0

我试图使用ASP.NET发送电子邮件system.net.mail使用ASP.NET邮件与需要SSL

问题是,即将离任的服务器要求安全连接的发送服务器(SSL)

有谁知道我该如何实现这个?

谢谢!

回答

1

这里的是Gmail的一个样本,它使用SSL:

class Program 
{ 
    static void Main(string[] args) 
    { 
     SmtpClient client = new SmtpClient("smtp.gmail.com", 587); 
     client.EnableSsl = true; 
     client.Credentials = new NetworkCredential("[email protected]", "secret"); 

     MailMessage mail = new MailMessage(); 
     mail.From = new MailAddress("[email protected]"); 
     mail.To.Add("[email protected]"); 
     mail.Subject = "Test mail"; 
     mail.Body = "test body"; 
     client.Send(mail); 
    } 
}