Merge pull request #2400 from esdrubal/extrahead
[mono.git] / mcs / class / System.Web / System.Web.Mail / SmtpMail.cs
index f547a2ca58c50df5dc0821b98764fecc32e36c02..3085a930752e064d21b8e45383793e6e4d0f7acc 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
+       [Obsolete ("The recommended alternative is System.Net.Mail.SmtpClient. http://go.microsoft.com/fwlink/?linkid=14202")]
+       public class SmtpMail
        {
-               private static string smtpServer = "localhost";
+               static string smtpServer = "localhost";
                
-               // Constructor          
-               private SmtpMail ()
+               // Constructor
+               SmtpMail ()
                {
                        /* empty */
-               }               
+               }
 
                // Properties
                public static string SmtpServer {
@@ -54,7 +54,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 +66,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 +104,5 @@ namespace System.Web.Mail
                        message.Body = messageText;
                        Send (message);
                }
-       
        }
-       
-} //namespace System.Web.Mail
+}