日期:2008-05-15  浏览次数:20431 次

namespace mySmtp
{

using System;
using System.Net;
using System.Net.Sockets;

using System.Text;
using System.Collections;


    interface ITransport
    {
        void setHost(String smtpHost);
        String getHost();
    
        void setPort(int smtpPort);
        int getPort();
    
        void sendMail(MailMessage msg);
    }


    public class Smtp : ITransport
    {
        private String smtpHost;
        private int smtpPort;
        
        public Smtp()
        {
            //smtpHost = "127.0.0.1";
            //smtpPort = 25;
        }
        
        public Smtp(String host, int port)
        {
            smtpHost = host;
            smtpPort = port;
        }
        
        
        public void setHost(String host)
        {
            smtpHost = host;
        }
        public String getHost()
        {
            return smtpHost;
        }
        
        
        public void setPort(int port)
        {
            smtpPort = port;
        }
        public int getPort()
        {
            return smtpPort;    
        }


        public void sendMail(MailMessage msg)
            
        {
        
            TcpClient tcpc = new TcpClient();

            try
            {
      &nb