New test + update
[mono.git] / mcs / class / System.Web / System.Web.Mail / SmtpMail.cs
index f547a2ca58c50df5dc0821b98764fecc32e36c02..0273f6ae1b46c12c499019445a1196bce6b059e0 100644 (file)
@@ -5,7 +5,7 @@
 //    Lawrence Pit (loz@cable.a2000.nl)
 //    Per Arneng (pt99par@student.bth.se) (SmtpMail.Send)
 //
-
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-using System;
 using System.Net;
 using System.Net.Sockets;
 using System.Text;
 using System.IO;
 using System.Reflection;
+using System.Security.Permissions;
 
 namespace System.Web.Mail
 {
-       /// <remarks>
-       /// </remarks>
-       public class SmtpMail
+       // CAS
+       [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+       [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+#if NET_2_0
+       [Obsolete ("The recommended alternative is System.Net.Mail.SmtpClient.")]
+#endif
+       public class SmtpMail
        {
                private static string smtpServer = "localhost";
                
@@ -54,7 +58,9 @@ namespace System.Web.Mail
                        set { smtpServer = value; }
                }
                
-               
+               // Medium (not Minimal) here
+               // http://msdn.microsoft.com/library/en-us/dnpag2/html/paght000017.asp
+               [AspNetHostingPermission (SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Medium)]
                public static void Send (MailMessage message) 
                {
                                                    
@@ -64,17 +70,7 @@ namespace System.Web.Mail
                        // access to properties and to add some functionality
                        MailMessageWrapper messageWrapper = new MailMessageWrapper( message );
                        
-#if TARGET_JVM
-                       string currentSmtpServer = smtpServer;
-                       if (currentSmtpServer == "localhost")
-                       {
-                               java.net.InetAddress address = java.net.InetAddress.getLocalHost();
-                               currentSmtpServer = address.getHostAddress();
-                       }
-                       SmtpClient smtp = new SmtpClient (currentSmtpServer);
-#else
                        SmtpClient smtp = new SmtpClient (smtpServer);
-#endif
                        
                        smtp.Send (messageWrapper);
                       
@@ -112,7 +108,5 @@ namespace System.Web.Mail
                        message.Body = messageText;
                        Send (message);
                }
-       
        }
-       
-} //namespace System.Web.Mail
+}