×

Loading...
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务

System.Net.Dns can only provide simple domain name resolution functionality. but I need find out Mail Exchange Server IP address. like this:

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

U:\>nslookup
*** Can't find server name for address 172.16.0.10: Non-existent domain
*** Default servers are not available
Default Server: UnKnown
Address: 172.16.0.10

> set type=MX
> hotmail.com
Server: UnKnown
Address: 172.16.0.10

Non-authoritative answer:
hotmail.com MX preference = 5, mail exchanger = mx2.hotmail.com
hotmail.com MX preference = 5, mail exchanger = mx3.hotmail.com
hotmail.com MX preference = 5, mail exchanger = mx4.hotmail.com
hotmail.com MX preference = 5, mail exchanger = mx1.hotmail.com
>
Report

Replies, comments and Discussions:

  • 工作学习 / 学科技术讨论 / 想写一个小程序, 功能:分析一个文本文件,提取里面的部分信息,然后自动生成email发送出去。现在不知道怎么能够“自动生成email并且发送出去”, 那位知道能否指点一下?
    • 不是啥难事。但你这样问倒也不易解释清楚,假设你用OUTLOOK,就找点程序中如何用OUTLOOK的部件的文章吧,简单;如果啥部件都不用,就的按SMTP协议自己做个部件,没做过可能有点难度。许多开发环境都提供SMTP部件。
    • 用sendmail巴,写个一行script. 基本上是 letter="From: To: Subject: blah blah"; echo $letter | sendmail -t xxx 什么的
      • 谢谢回答!! 我用c#试了一下,怎么也调不通。也用了smtp类。 我希望程序越简单越好。有做过类似的吗?
        • 两种方法: 1. 用SmtpMail 类和MailMessage类(需要设置SmtpServer ); 2.用SQL Server SendMail存储过程 (需要安装和设置Outlook)
          • i am using Smtpclient, when using yahoo mail, got an error: "You are not authorized to send mail, authentication is required", when i use gmail, got an error: "the operation has time out". the settings and code are the same as the other programers.
            i am using Smtpclient, when using yahoo mail, got an error: "You are not authorized to send mail, authentication is required", when i use gmail, got an error: "the operation has time out". the settings and code are the same as the other programers. i checked this link: http://www.aspxboy.com/private/5568/default.aspx , but mine still does not work. BTW, i am using c#. anyone can help?
            • It looks like you need credential info for authorization.
              Try following code to provide credential info:

              SmtpClient client = new SmtpClient();
              client.Host = "HOST Server IP/Name";
              client.Port = Port Number;
              client.Credentials = new System.Net.NetworkCredential("Uer_ID", "Pass Word", "Domain");
              client.Send(...);

              HTH
              • i tried, it still does not work. maybe the 2008 c# and the frame work have sme tricks?
                • I don't think so. If you really doubt about .NET FW 3.5, you can switch FW to 2.0.
                  BTW, did you configure outlook (or outlook express) in your computer to connect to yahoo mail? If not, have it done and to see if it works or not.
                  • yes, i configured my outlook express in several computers to connect to the yahoo mails, I used out look for several years. no any problems. wierd
                    • If you tried every thing of SmtpClient unsuccessfully, the workaround is to try Outlook automation.
        • Use Perl is simple,几句话。我有Java 的例子,也非常简单。
    • i used Perl to do this.
    • 这件事分成两步来做. 第一步,分析文件, 生成email所有的信息, recipient, subject, body, etc, .NET中方法有很多; 第二步, 把EMAIL发出去, 见连接. yahoo, gmail等的smtp不一定能随便用的, 反正我记得以前是用一个工具, 才能access locally.
      • I list the code here, everything is ok, build successfully. when try to send the email, got the error: The SMTP server requires a secure connection or the client was not authenticated.
        The SMTP server requires a secure connection or the client was not authenticated. The server response was: authentication required - for help go to http://help.yahoo.com/help/us/bizmail/pop/pop-11.html

        MailMessage message = new MailMessage();
        message.From = new MailAddress("service@****.com");
        message.To.Add(new MailAddress("sales@***.com"));
        message.Subject = "This is my subject";
        message.Body = "This is the content";
        SmtpClient client = new SmtpClient();
        client.Send(message);

        the following code is in the app.config file(the setting works in my outlook express):

        <system.net>
        <mailSettings>
        <smtp from="service@***.com">
        <network host="smtp.bizmail.yahoo.com" port="587" userName="service@***.com" password="****" defaultCredentials="true" />
        </smtp>
        </mailSettings>
        </system.net>

        the
        • If your program and version are not listed above, you may have trouble connecting to the Yahoo! Mail SMTP servers. Yahoo! does not support other programs and versions.
          • program and version? Can you explain it? which program and version should I specify?
            • http://help.yahoo.com/help/us/bizmail/pop/pop-11.html
            • 要是你的机器安装smtp service了,用localhost吧
              • i pay yahoo for the service. the problem is i could not send email by gmail either. and how can I set up the smtp service , local host? Thanks again.
        • Remove defaultCredentials="true" from configuration
          If you set defaultCredentials to true and specify a user name and password, the default network credential is used, and the basic authentication data is ignored.
          • 很有可能
            • i removed Remove defaultCredentials="true" from configuration , but the error is the same
              • 那就是不支持他人自行开发的发送邮件程序。一般MAIL SERVER只允许局域网内部的程序自动发送MAIL。反向思维以下,全世界千白万程序员,只要有一个人使坏,就可以是MAIL SERVER瞬间超载。
                • gmail 应该支持他人自行开发的发送邮件程序, 我查了许多例子,很多人都在用。
                  • 我是成功用过YAHOO转发的(仅作测试),还是用的免费信箱,PORT用缺省值(25)。没看到你的环境,原因很多,比如你的机器装了防病毒程序等。
                    • 你看了我的code吗? 哪儿有什么不对的?请指点一下,我用vista, c#2008. 几台机子都试过了。没装防病毒程序。真是奇怪呀。要不post你的程序我看一看?
                      • 到www.yahoo.ca注册个信箱。下面这段代码是工作的(VS 2005,Windos XP)。
                        Dim myMail As New System.Net.Mail.MailMessage
                        myMail.From = New System.Net.Mail.MailAddress("XXXXXX@yahoo.ca")
                        myMail.To.Add(New System.Net.Mail.MailAddress("AAA@BBB.CCC"))
                        myMail.Subject = "Subject"
                        myMail.Body = "Body"

                        Dim mySmtpClient As New System.Net.Mail.SmtpClient

                        mySmtpClient.Host = "smtp.mail.yahoo.com"

                        Dim myNetworkCredential As New NetworkCredential( _
                        "XXXXXX", _
                        "Password")
                        mySmtpClient.UseDefaultCredentials = False
                        mySmtpClient.Credentials = myNetworkCredential
                        mySmtpClient.Send(myMail)
                        MsgBox("OK")
                    • 我用了yahoo的普通邮箱试了一下,port 25 doesnot work. if using port 587, the same error. i checked your code, it is exactly the same as mine. the difference is i use 2008 c# and win vista. 怪了。 maybe 哪儿的设置有问题?
                      • 估计还是你的代码有问题。注册个信箱,把代码原封不动地贴上来看看。
                        • ok, here it is,代码原封不动地贴上来了。 是一个win application, i added a button, when i click the button, 执行代码。
                          本文发表在 rolia.net 枫下论坛using System;
                          using System.Collections.Generic;
                          using System.ComponentModel;
                          using System.Data;
                          using System.Drawing;
                          using System.Linq;
                          using System.Text;
                          using System.Windows.Forms;
                          using System.Net;
                          using System.Net.Mail;

                          namespace WindowsFormsApplication1
                          {
                          public partial class Form1 : Form
                          {
                          public Form1()
                          {
                          InitializeComponent();
                          }

                          private void button1_Click(object sender, EventArgs e)
                          {

                          MailMessage message = new MailMessage();

                          message.From = new MailAddress("gysun2222@yahoo.com");

                          message.To.Add(new MailAddress("gysun2222@yahoo.com"));

                          message.Subject = "This is my subject";

                          message.Body = "This is the content";

                          SmtpClient client = new SmtpClient();

                          client.Host = "smtp.mail.yahoo.com";
                          int port = 587;
                          client.Port = port;
                          client.UseDefaultCredentials = false;
                          client.Credentials = new NetworkCredential("gysun2222@yahoo.com", "197510");

                          client.Send(message);

                          }
                          }
                          }更多精彩文章及讨论,请光临枫下论坛 rolia.net
                          • Try this: client.Credentials = new NetworkCredential("gysun2222", "197510");
                            • tried just now, no luck. when you used it, it works?
                              • Yes
                                • i still got the same error as follows, and the program is "no response", when i close it, "vshost.exe not response" , i am using vista, 2008 c#,
                                  The SMTP server requires a secure connection or the client was not authenticated. The server response was: authentication required - for help go to http://help.yahoo.com/help/us/mail/pop/pop-11.html,
                                  • 还是有些不一样的,我说的是我在www.yahoo.ca走通,你一直在www.yahoo.com上转,再试试吧。
                                    • 另外我用PORT=25
                                    • Outgoing (SMTP) Server: smtp.mail.yahoo.com (Use SSL, port: 465, use authentication)
                                    • 刚刚用你的信箱试试,我也有一样的问题。看来www.yahoo.ca上注册的信箱可以,www.yahoo.com注册的不行
                                      • port 25 works? it never worked for me, it does not matter where i am(Canada, USA), i can use port 587 only, and it seems yahoo does not use SSL, i tried port 465, does not work either. BTW, you use prot 25 or port 465?
                                        • Take a look at my code. I didn't set port at all. I use default.
                                          • i tried gmail, the error is different: the operation has time out. code 本身好像没问题,不知道问题出在哪儿。
                                            • I tried following code with my gmail account. no problem!
                                              本文发表在 rolia.net 枫下论坛public void TestSendMail()
                                              {
                                              //Create Mail Message Object with content that you want to send with mail.
                                              System.Net.Mail.MailMessage MyMailMessage = new System.Net.Mail.MailMessage("your.account@gmail.com", "other.account@gmail.com",
                                              "This is the mail subject", "Just wanted to say Hello");

                                              MyMailMessage.IsBodyHtml = false;

                                              //Proper Authentication Details need to be passed when sending email from gmail
                                              System.Net.NetworkCredential mailAuthentication = new
                                              System.Net.NetworkCredential("your.account@gmail.com", "something_secret");

                                              //Smtp Mail server of Gmail is "smpt.gmail.com" and it uses port no. 587
                                              //For different server like yahoo this details changes and you can
                                              //get it from respective server.
                                              System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587);

                                              //Enable SSL
                                              mailClient.EnableSsl = true;

                                              mailClient.UseDefaultCredentials = false;

                                              mailClient.Credentials = mailAuthentication;

                                              mailClient.Send(MyMailMessage);
                                              }更多精彩文章及讨论,请光临枫下论坛 rolia.net
    • 嘿嘿,我首先用dnslookup找到对方mail server的ip,然后直接用socket连对方的port 25,用smtp协议发,除了有时候会进去垃圾箱,都不错。
      • dnslookup
        本文发表在 rolia.net 枫下论坛using System;
        using System.Runtime.InteropServices;
        using System.Collections;

        namespace MyCommon
        {

        public class DNS
        {
        /// <summary>
        /// Dll Entrypoint for DNS Services
        /// </summary>
        [DllImport("dnsapi.dll",EntryPoint="DnsQuery_A")]
        private static extern UInt32 DnsQuery( [MarshalAs(UnmanagedType.LPStr)]string lpstrName, [MarshalAs(UnmanagedType.U2)]UInt16 wType, [MarshalAs(UnmanagedType.U4)]UInt32 fOptions, [MarshalAs(UnmanagedType.LPStr)]string DNSServer, ref UInt32 prr, [MarshalAs(UnmanagedType.U4)]UInt32 t3 );

        private string _DNSServer = null;
        public string DNSServer
        {
        get
        {
        return _DNSServer;
        }
        set
        {
        _DNSServer = value;
        }
        }
        public DNS(){}

        public DNS(string DNSServer)
        {
        _DNSServer = DNSServer;
        }

        public IEnumerator LookupAll( String strDomain )
        {
        return( Lookup( ref strDomain, DNSTypes.DNS_TYPE_ALL, DNSTypes.DNS_QUERY_STANDARD | DNSTypes.DNS_QUERY_TREAT_AS_FQDN | DNSTypes.DNS_QUERY_BYPASS_CACHE ) );
        }

        public IEnumerator LookupMX( String strDomain )
        {
        return( Lookup( ref strDomain, DNSTypes.DNS_TYPE_MX, DNSTypes.DNS_QUERY_STANDARD | DNSTypes.DNS_QUERY_TREAT_AS_FQDN | DNSTypes.DNS_QUERY_BYPASS_CACHE ) );
        }

        public IEnumerator LookupA( String strDomain )
        {
        return( Lookup( ref strDomain, DNSTypes.DNS_TYPE_A, DNSTypes.DNS_QUERY_STANDARD | DNSTypes.DNS_QUERY_TREAT_AS_FQDN | DNSTypes.DNS_QUERY_BYPASS_CACHE ) );
        }

        public IEnumerator Lookup( String strDomain, UInt16 dnstype, UInt32 querytype )
        {
        return( Lookup( ref strDomain, dnstype, querytype ) );
        }

        /// <summary>
        /// Used to verify a domain for any type of record
        /// </summary>
        /// <param name="strDomain"></param>
        /// <returns></returns>
        private IEnumerator Lookup( ref string strDomain, UInt16 dnstype, UInt32 querytype )
        {
        DNS_RECORD dnsrec;
        DNS_WRAPPER wrapper;

        UInt32 ppQueryResultsSet = 0;
        object Data = new object();

        ArrayList list = new ArrayList();

        try
        {
        uint temp = DnsQuery( strDomain, dnstype, querytype, _DNSServer, ref ppQueryResultsSet, (UInt32)0 );
        if( DnsQuery( strDomain, dnstype, querytype, _DNSServer, ref ppQueryResultsSet, (UInt32)0 ) == 0 )
        {
        IntPtr ppr = new IntPtr( ppQueryResultsSet );

        // Parse the records.
        // Call function to loop through linked list and fill an array of records
        do
        {
        // Get the DNS_RECORD
        dnsrec = (DNS_RECORD)Marshal.PtrToStructure( ppr, typeof(DNS_RECORD) );

        // Get the Data part
        GetData( ppr.ToInt32(), ref dnsrec, ref Data );

        // Wrap data in a struct with the type and data
        wrapper = new DNS_WRAPPER();
        wrapper.dnsType = dnsrec.wType;
        wrapper.dnsData = Data;


        // Add wrapper to array
        list.Add( wrapper );

        ppr = dnsrec.pNext;

        } while ( ppr.ToInt32() != 0 );

        }
        }
        catch
        {

        }

        return( list.GetEnumerator() );

        } // end of VerifyDomain

        private void GetData( Int32 ptr, ref DNS_RECORD dnsrec, ref object Data )
        {
        ptr += Marshal.SizeOf( dnsrec );// Skip over the header portion of the DNS_RECORD to the data portion.
        //ptr += 24;
        switch ( dnsrec.wType )
        {
        case DNSTypes.DNS_TYPE_A:
        Data = (DNS_A_DATA)Marshal.PtrToStructure( new IntPtr(ptr), typeof(DNS_A_DATA) );
        break;
        case DNSTypes.DNS_TYPE_CNAME:
        case DNSTypes.DNS_TYPE_MB:
        case DNSTypes.DNS_TYPE_MD:
        case DNSTypes.DNS_TYPE_MF:
        case DNSTypes.DNS_TYPE_MG:
        case DNSTypes.DNS_TYPE_MR:
        case DNSTypes.DNS_TYPE_NS:
        case DNSTypes.DNS_TYPE_PTR:
        Data = (DNS_PTR_DATA)Marshal.PtrToStructure( new IntPtr(ptr), typeof(DNS_PTR_DATA) );
        break;
        case DNSTypes.DNS_TYPE_HINFO:
        case DNSTypes.DNS_TYPE_ISDN:
        case DNSTypes.DNS_TYPE_X25:
        Data = (DNS_TXT_DATA)Marshal.PtrToStructure( new IntPtr(ptr), typeof(DNS_TXT_DATA) );
        break;
        case DNSTypes.DNS_TYPE_MINFO:
        case DNSTypes.DNS_TYPE_RP:
        Data = (DNS_MINFO_DATA)Marshal.PtrToStructure( new IntPtr(ptr), typeof(DNS_MINFO_DATA) );
        break;
        case DNSTypes.DNS_TYPE_MX:
        case DNSTypes.DNS_TYPE_AFSDB:
        case DNSTypes.DNS_TYPE_RT:
        Data = (DNS_MX_DATA)Marshal.PtrToStructure( new IntPtr(ptr), typeof(DNS_MX_DATA) );
        break;
        case DNSTypes.DNS_TYPE_NULL:
        Data = (DNS_NULL_DATA)Marshal.PtrToStructure( new IntPtr(ptr), typeof(DNS_NULL_DATA) );
        break;
        case DNSTypes.DNS_TYPE_SOA:
        Data = (DNS_SOA_DATA)Marshal.PtrToStructure( new IntPtr(ptr), typeof(DNS_SOA_DATA) );
        break;
        case DNSTypes.DNS_TYPE_WKS:
        Data = (DNS_WKS_DATA)Marshal.PtrToStructure( new IntPtr(ptr), typeof(DNS_WKS_DATA) );
        break;
        case DNSTypes.DNS_TYPE_AAAA:
        Data = (DNS_AAAA_DATA)Marshal.PtrToStructure( new IntPtr(ptr), typeof(DNS_AAAA_DATA) );
        break;
        case DNSTypes.DNS_TYPE_ATMA:
        Data = (DNS_ATMA_DATA)Marshal.PtrToStructure( new IntPtr(ptr), typeof(DNS_ATMA_DATA) );
        break;
        case DNSTypes.DNS_TYPE_NBSTAT:
        //case DNS_TYPE_WINSR:
        Data = (DNS_WINSR_DATA)Marshal.PtrToStructure( new IntPtr(ptr), typeof(DNS_WINSR_DATA) );
        break;
        case DNSTypes.DNS_TYPE_SRV:
        Data = (DNS_SRV_DATA)Marshal.PtrToStructure( new IntPtr(ptr), typeof(DNS_SRV_DATA) );
        break;
        case DNSTypes.DNS_TYPE_TKEY:
        Data = (DNS_TKEY_DATA)Marshal.PtrToStructure( new IntPtr(ptr), typeof(DNS_TKEY_DATA) );
        break;
        case DNSTypes.DNS_TYPE_TSIG:
        Data = (DNS_TSIG_DATA)Marshal.PtrToStructure( new IntPtr(ptr), typeof(DNS_TSIG_DATA) );
        break;
        case DNSTypes.DNS_TYPE_WINS:
        Data = (DNS_WINS_DATA)Marshal.PtrToStructure( new IntPtr(ptr), typeof(DNS_WINS_DATA) );
        break;
        case DNSTypes.DNS_TYPE_LOC:
        Data = (DNS_LOC_DATA)Marshal.PtrToStructure( new IntPtr(ptr), typeof(DNS_LOC_DATA) );
        break;
        case DNSTypes.DNS_TYPE_AXFR:
        case DNSTypes.DNS_TYPE_GPOS:
        case DNSTypes.DNS_TYPE_IXFR:
        case DNSTypes.DNS_TYPE_KEY:
        case DNSTypes.DNS_TYPE_MAILA:
        case DNSTypes.DNS_TYPE_MAILB:
        case DNSTypes.DNS_TYPE_NSAP:
        case DNSTypes.DNS_TYPE_NSAPPTR:
        case DNSTypes.DNS_TYPE_NXT:
        case DNSTypes.DNS_TYPE_PX:
        case DNSTypes.DNS_TYPE_SIG:
        case DNSTypes.DNS_TYPE_TEXT:
        default:
        Data = null;
        break;
        }// end of switch for each dns record type

        }// end of GetDataType

        /// <summary>
        /// Structure for the actual DNS Record
        /// </summary>
        [StructLayout(LayoutKind.Sequential)]
        private struct DNS_RECORD
        {
        // public IntPtr pNext;
        public IntPtr pNext;// 4 bytes
        //[MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPTStr)]
        public string pName;// 4 bytes
        [MarshalAs(System.Runtime.InteropServices.UnmanagedType.U2)] public UInt16 wType;// 2 bytes
        [MarshalAs(System.Runtime.InteropServices.UnmanagedType.U2)] public UInt16 wDataLength;// 2 bytes
        [ StructLayout( LayoutKind.Explicit )]// 4 bytes
        public struct DNS_RECORD_FLAGS
        {
        [ FieldOffset( 0 )]
        [MarshalAs(System.Runtime.InteropServices.UnmanagedType.U4)] public UInt32 DW;
        [ FieldOffset( 0 )]
        [MarshalAs(System.Runtime.InteropServices.UnmanagedType.U4)] public UInt32 S;
        }// end of union for flags
        public DNS_RECORD_FLAGS flags;
        [MarshalAs(System.Runtime.InteropServices.UnmanagedType.U4)] public UInt32 dwTtl;// 4 bytes
        [MarshalAs(System.Runtime.InteropServices.UnmanagedType.U4)] public UInt32 dwReserved;// 4 bytes
        // Can't fill in rest of the structure because if it doesn't line up, c# will complain.

        } // end of struct _DnsRecord


        }// end of class CDNS

        /// <summary>
        /// Structure for the DNS_WRAPPER
        /// </summary>
        public struct DNS_WRAPPER
        {
        public UInt16 dnsType;
        public object dnsData;

        }// end of DNS_IP6_ADDRESS

        /// <summary>
        /// Structure for the DNS_IP6_ADDRESS
        /// </summary>
        public struct DNS_IP6_ADDRESS
        {
        public UInt16 IP6Word1;
        public UInt16 IP6Word2;
        public UInt16 IP6Word3;
        public UInt16 IP6Word4;
        public UInt16 IP6Word5;
        public UInt16 IP6Word6;
        public UInt16 IP6Word7;
        public UInt16 IP6Word8;
        }// end of DNS_IP6_ADDRESS

        [StructLayout(LayoutKind.Sequential)]
        public struct DNS_A_DATA
        {
        public UInt32 IpAddress;
        }// end of DNS_A_DATA

        [StructLayout(LayoutKind.Sequential)]
        public struct DNS_SOA_DATA
        {
        public string pNamePrimaryServer;
        public string pNameAdministrator;
        public UInt32 dwSerialNo;
        public UInt32 dwRefresh;
        public UInt32 dwRetry;
        public UInt32 dwExpire;
        public UInt32 dwDefaultTtl;
        }// end of DNS_SOA_DATA

        [StructLayout(LayoutKind.Sequential)]
        public struct DNS_PTR_DATA
        {
        public string pNameHost;
        }// end of DNS_PTR_DATA

        [StructLayout(LayoutKind.Sequential)]
        public struct DNS_MINFO_DATA
        {
        public string pNameMailbox;
        public string pNameErrorsMailbox;
        }// end of DNS_MINFO_DATA

        [StructLayout(LayoutKind.Sequential)]
        public struct DNS_MX_DATA
        {
        public string pNameExchange;
        public UInt16 wPreference;
        public UInt16 wPad; // to keep dword aligned
        }// end of DNS_MX_DATA

        [StructLayout(LayoutKind.Sequential)]
        public struct DNS_TXT_DATA
        {
        public UInt32 dwStringCount;
        public string pStringArray;
        }// end of DNS_TXT_DATA
        [StructLayout(LayoutKind.Sequential)]
        public struct DNS_NULL_DATA
        {
        public UInt32 dwByteCount;
        public string pData;
        }// end of DNS_NULL_DATA
        [StructLayout(LayoutKind.Sequential)]
        public struct DNS_WKS_DATA
        {
        public UInt32 IpAddress;
        public char chProtocol;
        public byte BitMask;
        }// end of DNS_WKS_DATA
        [StructLayout(LayoutKind.Sequential)]
        public struct DNS_AAAA_DATA
        {
        public DNS_IP6_ADDRESS Ip6Address;
        }// end of DNS_AAAA_DATA
        [StructLayout(LayoutKind.Sequential)]
        public struct DNS_KEY_DATA
        {
        public UInt16 wFlags;
        public byte chProtocol;
        public byte chAlgorithm;
        public byte Key;
        }// end of DNS_KEY_DATA
        [StructLayout(LayoutKind.Sequential)]
        public struct DNS_LOC_DATA
        {
        public UInt16 wVersion;
        public UInt16 wSize;
        public UInt16 wHorPrec;
        public UInt32 dwLatitude;
        public UInt32 dwLongitude;
        public UInt32 dwAltitude;
        }// end of DNS_LOC_DATA
        [StructLayout(LayoutKind.Sequential)]
        public struct DNS_SIG_DATA
        {
        public string pNameSigner;
        public UInt16 wTypeCovered;
        public byte chAlgorithm;
        public byte chLabelCount;
        public UInt32 dwOriginalTtl;
        public UInt32 dwExpiration;
        public UInt32 dwTimeSigned;
        public UInt16 wKeyTag;
        public UInt16 Pad; // keep byte field aligned
        public byte Signature;
        }// end of DNS_SIG_DATA
        [StructLayout(LayoutKind.Sequential)]
        public struct DNS_ATMA_DATA
        {
        public byte AddressType;
        public string Address;
        }// end of DNS_ATMA_DATA
        [StructLayout(LayoutKind.Sequential)]
        public struct DNS_NXT_DATA
        {
        public string pNameNext;
        public byte bTypeBitMap;
        }// end of DNS_NXT_DATA
        [StructLayout(LayoutKind.Sequential)]
        public struct DNS_SRV_DATA
        {
        public string pNameNext;
        public UInt16 wPriority;
        public UInt16 wWeight;
        public UInt16 wPort;
        public UInt16 Pad;
        }// end of DNS_SRV_DATA
        [StructLayout(LayoutKind.Sequential)]
        public struct DNS_TKEY_DATA
        {
        public string pNameAlgorithm;
        public IntPtr pAlgorithmPacket;
        public IntPtr pKey;
        public IntPtr pOtherData;
        public UInt32 dwCreateTime;
        public UInt32 ExpireTime;
        public UInt16 wMode;
        public UInt16 wError;
        public UInt16 wKeyLength;
        public UInt16 wOtherLength;
        public char cAlgNameLength;
        public bool bPacketPointers;
        }// end of DNS_TKEY_DATA
        [StructLayout(LayoutKind.Sequential)]
        public struct DNS_TSIG_DATA
        {
        public string pNameAlgorithm;
        public IntPtr pAlgorithmPacket;
        public IntPtr pKey;
        public IntPtr pOtherData;
        public UInt64 i64CreateTime;
        public UInt16 wFudgeTime;
        public UInt16 wOriginalXid;
        public UInt16 wError;
        public UInt16 wKeyLength;
        public UInt16 wOtherLength;
        public char cAlgNameLength;
        public bool bPacketPointers;
        }// end of DNS_TSIG_DATA
        [StructLayout(LayoutKind.Sequential)]
        public struct DNS_WINS_DATA
        {
        public UInt32 dwMappingFlag;
        public UInt32 dwLookupTimeout;
        public UInt32 dwCacheTimeout;
        public UInt32 cWinsServerCount;
        public UInt32 WinsServers;
        }// end of DNS_WINS_DATA
        [StructLayout(LayoutKind.Sequential)]
        public struct DNS_WINSR_DATA
        {
        public UInt32 dwMappingFlag;
        public UInt32 dwLookupTimeout;
        public UInt32 dwCacheTimeout;
        public string pNameResultDomain;
        }// end of DNS_WINSR_DATA

        public struct DNSTypes
        {
        /// <summary>
        /// Various DNS record types
        /// </summary>
        public const UInt16 DNS_TYPE_A = 0x0001; // 1
        public const UInt16 DNS_TYPE_NS = 0x0002; // 2
        public const UInt16 DNS_TYPE_MD = 0x0003; // 3
        public const UInt16 DNS_TYPE_MF = 0x0004; // 4
        public const UInt16 DNS_TYPE_CNAME = 0x0005; // 5
        public const UInt16 DNS_TYPE_SOA = 0x0006; // 6
        public const UInt16 DNS_TYPE_MB = 0x0007; // 7
        public const UInt16 DNS_TYPE_MG = 0x0008; // 8
        public const UInt16 DNS_TYPE_MR = 0x0009; // 9
        public const UInt16 DNS_TYPE_NULL = 0x000a; // 10
        public const UInt16 DNS_TYPE_WKS = 0x000b; // 11
        public const UInt16 DNS_TYPE_PTR = 0x000c; // 12
        public const UInt16 DNS_TYPE_HINFO = 0x000d; // 13
        public const UInt16 DNS_TYPE_MINFO = 0x000e; // 14
        public const UInt16 DNS_TYPE_MX = 0x000f; // 15
        public const UInt16 DNS_TYPE_TEXT = 0x0010; // 16
        // RFC 1183
        public const UInt16 DNS_TYPE_RP = 0x0011; // 17
        public const UInt16 DNS_TYPE_AFSDB = 0x0012; // 18
        public const UInt16 DNS_TYPE_X25 = 0x0013; // 19
        public const UInt16 DNS_TYPE_ISDN = 0x0014; // 20
        public const UInt16 DNS_TYPE_RT = 0x0015; // 21

        // RFC 1348
        public const UInt16 DNS_TYPE_NSAP = 0x0016; // 22
        public const UInt16 DNS_TYPE_NSAPPTR = 0x0017; // 23

        // RFC 2065 (DNS security)
        public const UInt16 DNS_TYPE_SIG = 0x0018; // 24
        public const UInt16 DNS_TYPE_KEY = 0x0019; // 25

        // RFC 1664 (X.400 mail)
        public const UInt16 DNS_TYPE_PX = 0x001a; // 26

        // RFC 1712 (Geographic position)
        public const UInt16 DNS_TYPE_GPOS = 0x001b; // 27

        // RFC 1886 (IPv6 Address)
        public const UInt16 DNS_TYPE_AAAA = 0x001c; // 28

        // RFC 1876 (Geographic location)
        public const UInt16 DNS_TYPE_LOC = 0x001d; // 29

        // RFC 2065 (Secure negative response)
        public const UInt16 DNS_TYPE_NXT = 0x001e; // 30

        // RFC 2052 (Service location)
        public const UInt16 DNS_TYPE_SRV = 0x0021; // 33

        // ATM Standard something-or-another
        public const UInt16 DNS_TYPE_ATMA = 0x0022; // 34

        //
        // Query only types (1035, 1995)
        //
        public const UInt16 DNS_TYPE_TKEY = 0x00f9; // 249
        public const UInt16 DNS_TYPE_TSIG = 0x00fa; // 250
        public const UInt16 DNS_TYPE_IXFR = 0x00fb; // 251
        public const UInt16 DNS_TYPE_AXFR = 0x00fc; // 252
        public const UInt16 DNS_TYPE_MAILB = 0x00fd; // 253
        public const UInt16 DNS_TYPE_MAILA = 0x00fe; // 254
        public const UInt16 DNS_TYPE_ALL = 0x00ff; // 255
        public const UInt16 DNS_TYPE_ANY = 0x00ff; // 255

        //
        // Temp Microsoft types -- use until get IANA approval for real type
        //
        public const UInt16 DNS_TYPE_WINS = 0xff01; // 64K - 255
        public const UInt16 DNS_TYPE_WINSR = 0xff02; // 64K - 254
        public const UInt16 DNS_TYPE_NBSTAT = DNS_TYPE_WINSR;
        /// <summary>
        /// Various DNS query types
        /// </summary>
        public const UInt32 DNS_QUERY_STANDARD = 0x00000000;
        public const UInt32 DNS_QUERY_ACCEPT_TRUNCATED_RESPONSE = 0x00000001;
        public const UInt32 DNS_QUERY_USE_TCP_ONLY = 0x00000002;
        public const UInt32 DNS_QUERY_NO_RECURSION = 0x00000004;
        public const UInt32 DNS_QUERY_BYPASS_CACHE = 0x00000008;
        public const UInt32 DNS_QUERY_CACHE_ONLY = 0x00000010;
        public const UInt32 DNS_QUERY_SOCKET_KEEPALIVE = 0x00000100;
        public const UInt32 DNS_QUERY_TREAT_AS_FQDN = 0x00001000;
        public const UInt32 DNS_QUERY_ALLOW_EMPTY_AUTH_RESP = 0x00010000;
        public const UInt32 DNS_QUERY_DONT_RESET_TTL_VALUES = 0x00100000;
        public const UInt32 DNS_QUERY_RESERVED = 0xff000000;
        }


        } // end namespace更多精彩文章及讨论,请光临枫下论坛 rolia.net
        • Why didn’t you look at System.Net.Dns?
          • System.Net.Dns can only provide simple domain name resolution functionality. but I need find out Mail Exchange Server IP address. like this:
            Microsoft Windows XP [Version 5.1.2600]
            (C) Copyright 1985-2001 Microsoft Corp.

            U:\>nslookup
            *** Can't find server name for address 172.16.0.10: Non-existent domain
            *** Default servers are not available
            Default Server: UnKnown
            Address: 172.16.0.10

            > set type=MX
            > hotmail.com
            Server: UnKnown
            Address: 172.16.0.10

            Non-authoritative answer:
            hotmail.com MX preference = 5, mail exchanger = mx2.hotmail.com
            hotmail.com MX preference = 5, mail exchanger = mx3.hotmail.com
            hotmail.com MX preference = 5, mail exchanger = mx4.hotmail.com
            hotmail.com MX preference = 5, mail exchanger = mx1.hotmail.com
            >
      • smtpclient
        本文发表在 rolia.net 枫下论坛using System;
        using System.Net.Sockets;
        using System.Text;
        using System.Collections;
        using System.IO;

        namespace MyCommon
        {

        public class Attachment
        {
        public string filePath;
        public string fileName;

        public Attachment(string AttachmentPath,string AttachmentName)
        {
        filePath = AttachmentPath;
        fileName = AttachmentName;
        }
        public Attachment(string AttachmentPath)
        {
        filePath = AttachmentPath;
        fileName = Path.GetFileName(AttachmentPath);
        }
        public override bool Equals(object obj)
        {
        if(obj is Attachment)
        {
        Attachment att = (Attachment)obj;
        return (att.fileName == this.fileName && att.filePath == this.filePath);
        }
        else
        {
        return false;
        }
        }
        public override int GetHashCode()
        {
        return base.GetHashCode ();
        }


        }
        public class SmtpClient
        {
        private string _SmtpServer;
        private int _Prot;
        private string _UserName;
        private string _Password;
        public string Sender = string.Empty;
        public string SenderName = string.Empty;
        public ArrayList Receivers = new ArrayList();
        public ArrayList ccReceivers = new ArrayList();
        public ArrayList bccReceivers = new ArrayList();
        private ArrayList Attachments = new ArrayList();
        public string Subject = string.Empty;
        public string Body = string.Empty;
        public bool IsHtmlBody = false;
        public string AlternativeBody = string.Empty;

        private bool _login = false;
        private string _mimeVersion = "MIME-Version: 1.0\r\n";
        private string _mimeHTMLType = "Content-Type: text/html; charset=\"iso-8859-1\"\r\n";
        private string _mimeTextType = "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
        private string _mimeApplicationType1 = "Content-Type: application/octet-stream; \r\n";
        private string _mimeApplicationType2 = "Content-disposition: attachment; filename=\"@filename\"\r\n";
        private string _mimeMultiType = "Content-Type: multipart/mixed; boundary=\"abc\"\r\n";
        private string _mimeMultiTypeAlt = "Content-Type: multipart/alternative; boundary=\"abc\"\r\n";

        private string _encodingBase64String = "Content-transfer-encoding: base64\r\n\r\n";
        private string _encodingString = "Content-transfer-encoding: 8bit\r\n\r\n";
        private string _boundary = "\r\n\r\n--abc\r\n";
        private string _boundayend = "\r\n\r\n--abc--\r\n";
        private bool _HasAttatchment = false;
        private bool _NeedEndBoundary = false;

        private string _HTMLHeader = @"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.01 Transitional//EN"" ""http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd"">" + "\r\n";

        private TcpClient _mailClient = null;
        public SmtpClient(){}

        public SmtpClient(string SmtpServer,int Port,string UserName,string Password)
        {
        init(SmtpServer,Port,UserName,Password,true);
        }
        public SmtpClient(string SmtpServer,string UserName,string Password)
        {
        init(SmtpServer,25,UserName,Password,true);
        }
        public SmtpClient(string SmtpServer,int Port)
        {
        init(SmtpServer,Port,string.Empty,string.Empty,false);
        }
        public SmtpClient(string SmtpServer)
        {
        init(SmtpServer,25,string.Empty,string.Empty,false);
        }
        private void init(string SmtpServer,int Port,string UserName,string Password,bool Login)
        {
        _SmtpServer = SmtpServer;
        _Prot = Port;
        _UserName = Convert.ToBase64String(Encoding.ASCII.GetBytes(UserName));
        _Password = Convert.ToBase64String(Encoding.ASCII.GetBytes(Password));
        _login = Login;
        }
        public void addAttachment(Attachment attachment)
        {
        Attachments.Add(attachment);
        }
        public void clearAttachments()
        {
        Attachments.Clear();
        }
        public void removeAttachment(Attachment attachment)
        {
        Attachments.Remove(attachment);
        }
        private string[] getMXServer(string DomainName)
        {
        ArrayList mailServer = new ArrayList();
        DNS dns = new DNS();
        IEnumerator ienum = dns.LookupMX(DomainName);
        while( ienum.MoveNext() )
        {
        DNS_WRAPPER dnsentry = (DNS_WRAPPER)ienum.Current;
        if( dnsentry.dnsType == DNSTypes.DNS_TYPE_MX )
        {
        DNS_MX_DATA dnsmx = (DNS_MX_DATA)dnsentry.dnsData;
        mailServer.Add(dnsmx.pNameExchange);
        }
        }
        if(mailServer.Count >0)
        return (string[])mailServer.ToArray(typeof(string));
        else
        throw new Exception("Can not find Mail Server for domin " + DomainName);
        }


        private string getServerResponse()
        {
        byte[] serverbuff = new Byte[2048];
        NetworkStream stream = _mailClient.GetStream();
        int count = stream.Read( serverbuff, 0, 2048 );
        if (count == 0)
        {
        return "";
        }
        return Encoding.ASCII.GetString( serverbuff, 0, count );
        }

        private string getEncodingString(bool useBase64)
        {
        if(useBase64)
        {
        return _encodingBase64String;
        }
        else
        {
        return _encodingString;
        }
        }
        private void WriteCommand(string message)
        {
        byte[] WriteBuffer = Encoding.ASCII.GetBytes(message) ;

        NetworkStream stream = _mailClient.GetStream() ;
        stream.Write(WriteBuffer,0,WriteBuffer.Length);
        }
        private void WriteMessage(string message,Encoding encoder)
        {
        byte[] WriteBuffer = encoder.GetBytes(message) ;

        NetworkStream stream = _mailClient.GetStream() ;
        stream.Write(WriteBuffer,0,WriteBuffer.Length);
        }
        private void WriteMessage(string message,Encoding encoder, bool useBase64)
        {
        if(useBase64)
        {
        writeMessageBase64(message);
        }
        else
        {
        WriteMessage(message,encoder);
        }
        }
        private void writeMessageBase64(string message)
        {
        byte[] WriteBuffer = Encoding.ASCII.GetBytes(Convert.ToBase64String(Encoding.ASCII.GetBytes(message))) ;

        NetworkStream stream = _mailClient.GetStream() ;
        stream.Write(WriteBuffer,0,WriteBuffer.Length);

        }

        private void writeFileBase64(string FileName)
        {
        int length = 57;
        FileStream fs;
        byte[] buffer = new byte[length];
        int readLength;
        byte[] WriteBuffer;
        if(File.Exists(FileName))
        {
        //FileStream _fs = new FileStream(@"c:\readDate",FileMode.Create);
        NetworkStream stream = _mailClient.GetStream() ;
        FileInfo fInfo = new FileInfo(FileName);
        long filelength = fInfo.Length;
        fs = File.OpenRead(FileName);
        for(long i =0;i<filelength;i+= readLength)
        {
        fs.Position = i;
        readLength = fs.Read(buffer,0,length);
        WriteBuffer = Encoding.ASCII.GetBytes(Convert.ToBase64String(buffer,0,readLength)+ "\r\n") ;
        stream.Write(WriteBuffer,0,WriteBuffer.Length);
        //_fs.Write(WriteBuffer,0,WriteBuffer.Length);
        }
        fs.Close();
        //_fs.Close();
        }
        }

        private void writeFile(string FileName)
        {
        int length = 2048;
        FileStream fs;
        byte[] buffer = new byte[length];
        int readLength;
        byte[] WriteBuffer;
        if(File.Exists(FileName))
        {
        //FileStream _fs = new FileStream(@"c:\readDate",FileMode.Create);
        NetworkStream stream = _mailClient.GetStream() ;
        FileInfo fInfo = new FileInfo(FileName);
        long filelength = fInfo.Length;
        fs = File.OpenRead(FileName);
        for(long i =0;i<filelength;i+= readLength)
        {
        fs.Position = i;
        //_fs.Position = i;
        readLength = fs.Read(buffer,0,length);
        WriteBuffer = Encoding.ASCII.GetBytes(Encoding.UTF8.GetString(buffer,0,readLength)) ;
        stream.Write(WriteBuffer,0,WriteBuffer.Length);
        //_fs.Write(WriteBuffer,0,WriteBuffer.Length);
        }
        fs.Close();
        //_fs.Close();
        }
        }

        private void writeFile(string FileName,bool useBase64)
        {
        if(useBase64)
        {
        writeFileBase64(FileName);
        }
        else
        {
        writeFile(FileName);
        }
        }

        private void sendEmailOneByOne(string EmailAddress)
        {
        string message;
        string response;
        _NeedEndBoundary = false;
        bool connected = false;
        int serverIndex = 0;
        string log = string.Empty;

        try
        {
        _mailClient = new TcpClient();
        string[] serverName = new string[1];
        if(_SmtpServer != string.Empty)
        serverName[0] = _SmtpServer;
        else
        {
        string[] temp = EmailAddress.ToString().Split(new char[]{'@'});
        serverName = getMXServer(temp[1]);
        }
        while(!connected && serverIndex < serverName.Length)
        {
        try
        {
        _mailClient.Connect(serverName[0],25);
        connected = true;
        }
        catch
        {
        }
        serverIndex++;
        }
        if(!connected)
        throw new Exception("Cannot connect to Mail Server ");

        response = getServerResponse();
        if (response.Substring(0, 3) != "220")
        {
        throw new Exception(response);
        }

        message = "HELO \r\n";
        WriteCommand(message);
        response = getServerResponse();
        if (response.Substring(0, 3) != "250")
        {
        message = "HELO eclose \r\n";
        WriteCommand(message);
        response = getServerResponse();
        if (response.Substring(0, 3) != "250")
        {
        throw new Exception(response);
        }
        }
        if(_login)
        {
        message = "AUTH LOGIN\r\n";
        WriteCommand(message);
        response = getServerResponse();
        if( response != "334 VXNlcm5hbWU6\r\n")
        {
        throw new Exception(response);
        }

        WriteCommand(_UserName + "\r\n");
        response = getServerResponse();
        if( response != "334 UGFzc3dvcmQ6\r\n")
        {
        throw new Exception(response);
        }
        WriteCommand(_Password + "\r\n");
        response = getServerResponse();
        if (response.Substring(0, 3) != "235")
        {
        throw new Exception(response);
        }
        }

        message = "MAIL FROM: <" + Sender + ">\r\n";
        WriteCommand(message);
        response = getServerResponse();
        if (response.Substring(0, 3) != "250")
        {
        throw new Exception(response);
        }

        message = "RCPT TO:<" + EmailAddress + ">\r\n";
        WriteCommand(message);
        response = getServerResponse();
        if (response.Substring(0, 3) != "250")
        {
        throw new Exception(response);
        }

        message = "DATA\r\n";
        WriteCommand(message);
        response = getServerResponse();
        if (response.Substring(0, 3) != "354")
        {
        throw new Exception(response);
        }
        message = "From: " + "\"" + (SenderName==string.Empty?Sender:SenderName) + "\"<" + (Sender==string.Empty?SenderName:Sender) + ">" + "\r\n";
        foreach ( string address in Receivers )
        {
        message += "To: " + "\"" + address + "\"<" + address + ">" + "\r\n";
        }

        // foreach ( string address in ccReceivers )
        // {
        // message += "Cc: " + "\"" + address + "\"<" + address + ">" + "\r\n";
        // }

        message += "Subject: " + Subject + "\r\n";
        message += "Date: " + DateTime.Now.ToString("ddd, dd MMM yyyy HH:mm:ss zz00") + "\r\n";
        WriteCommand(message);

        _HasAttatchment = (Attachments.Count > 0);

        message = _mimeVersion;
        message += "X-Mailer: Internet Mail Service (5.5.2650.21)\r\n";
        if(_HasAttatchment)
        {
        message += _mimeMultiType;
        _NeedEndBoundary = true;
        }
        else if(IsHtmlBody)
        {
        message += _mimeMultiTypeAlt;
        _NeedEndBoundary = true;
        }
        message += "Return-Path: " + (Sender==string.Empty?SenderName:Sender) + "\r\n";
        if(_NeedEndBoundary)
        message += _boundary;

        message += _mimeTextType;
        message += getEncodingString(false);
        WriteCommand(message);

        if(IsHtmlBody)
        {
        if(Body.IndexOf(_HTMLHeader) < 0)
        {
        Body = _HTMLHeader + Body;
        }
        if(AlternativeBody != null && AlternativeBody != string.Empty)
        {
        message = AlternativeBody;
        }
        else
        {
        message = "Your email program settings cannot read HTML format email.\r\n";
        }
        message += _boundary;
        message += _mimeHTMLType;
        message += getEncodingString(false);
        WriteCommand(message);
        }

        WriteMessage(Body,Encoding.ASCII,false);

        if(_HasAttatchment)
        {
        foreach(Attachment attachment in Attachments)
        {
        message = _boundary + _mimeApplicationType1 + _mimeApplicationType2.Replace("@filename",attachment.fileName) + getEncodingString(true) ;
        WriteCommand(message);
        writeFile(attachment.filePath,true);
        }
        }
        if(_NeedEndBoundary)
        {
        WriteCommand(_boundayend);
        }
        // StreamReader sr = File.OpenText(@"c:\mailInfo.txt");
        // message = sr.ReadToEnd();
        // sr.Close();
        // WriteCommand(message);
        message = "\r\n.\r\n";
        WriteCommand(message);
        response = getServerResponse();
        if (response.Substring(0, 3) != "250")
        {
        throw new Exception(response);
        }

        message = "QUIT\r\n";
        WriteCommand(message);
        response = getServerResponse();
        if (response.IndexOf("221") == -1)
        {
        throw new Exception(response);
        }
        }
        catch(Exception e)
        {
        throw e;
        }
        finally
        {
        _mailClient.Close();
        }

        }
        public void Send()
        {
        foreach ( string address in Receivers )
        {
        sendEmailOneByOne(address);
        }

        foreach ( string address in ccReceivers )
        {
        sendEmailOneByOne(address);
        }

        foreach ( string address in bccReceivers )
        {
        sendEmailOneByOne(address);
        }
        }
        }
        }更多精彩文章及讨论,请光临枫下论坛 rolia.net
      • 以上是大概3年前在dotnet 1.1上用c#写的,要转发也可以,直接从本机发也可以。现在有些smtp server限制的更严了,可能发不到,主要是本机ip地址的问题,不过没心情改了。可以参考一下。
        • 程序能连到server, but 要求授权(yahoo)或连接超时(gmail),用户名和密码都正确。就是找不到原因。我联系了yahoo, yahoo 也说没问题,我看我的CODE好像也没问题。代码没几行。 真急人。
          using System;
          using System.Collections.Generic;
          using System.ComponentModel;
          using System.Data;
          using System.Drawing;
          using System.Linq;
          using System.Text;
          using System.Windows.Forms;
          using System.Net;
          using System.Net.Mail;

          namespace WindowsFormsApplication1
          {
          public partial class Form1 : Form
          {
          public Form1()
          {
          InitializeComponent();
          }

          private void button1_Click(object sender, EventArgs e)
          {

          MailMessage message = new MailMessage();

          message.From = new MailAddress("gysun2222@yahoo.com");

          message.To.Add(new MailAddress("gysun2222@yahoo.com"));

          message.Subject = "This is my subject";

          message.Body = "This is the content";

          SmtpClient client = new SmtpClient();

          client.Host = "smtp.mail.yahoo.com";
          int port = 587;
          client.Port = port;
          client.UseDefaultCredentials = false;
          client.Credentials = new NetworkCredential("gysun2222@yahoo.com", "197510");

          client.Send(message);

          }
          }
          }
          • 我的信箱是5年前注册的,刚刚上网看了看,好象亚虎对免费信箱不支持. Account Name/Login Name: Your Yahoo! Mail ID (your email address without the "@yahoo.com")
            • 我这个邮箱was registered 7 years ago. and I am using the paid yahoo service. yahoo told me it should be ok.
              • Try username without @yahoo.com
                • tried, not work
          • 我用telnet试了一下,你的用户名和密码无法登陆。我这里port 25没有问题。
            U:\>telnet smtp.mail.yahoo.com 25

            220 smtp103.plus.mail.re1.yahoo.com ESMTP
            HELO
            250 smtp103.plus.mail.re1.yahoo.com
            AUTH LOGIN
            334 VXNlcm5hbWU6
            gysun2222@yahoo.com
            501 malformed auth input (#5.5.4)
            535 authorization failed (#5.7.0)

            U:\>telnet smtp.mail.yahoo.com 25
            220 smtp108.plus.mail.re1.yahoo.com ESMTP
            HELO test
            250 smtp108.plus.mail.re1.yahoo.com
            AUTH LOGIN
            334 VXNlcm5hbWU6
            gysun2222
            334 UGFzc3dvcmQ6
            197510
            535 authorization failed (#5.7.0)
            • can not sign in? i can sign in using the IE.
              • 登陆web界面没问题,但是不能login smtp server
              • 不好意思,发用户名和密码的时候忘了BASE64编码了。我再试试。
              • 还是不行,你还是问问yahoo吧。
                • i can receive/send email by outlook express,the settings are the same. yahoo 也说没问题。“it should work”.
                  • outlook 不也是先连接到smtp server吗?
    • 报告你个消息,我的yahoo信箱也不行了。我有两个YAHOO信箱,一个用CLASSIC界面,一个用新界面,前者不行后者行,结果我把第二个信箱换会到CLASSIC界面后也不行了,再换回新界面也还是不行。
      • 对不起,还是行的,我的两个信箱都行。不行是我忘了diable防毒软件。 今天刚注册的一个不行。
        • 你的意思是你的两个yahoo 邮箱没问题,但是我的不行?并且你刚刚注册的也不行?just now i was calling yahoo after i saw your post, fortunately not connected. LOL
          • right
            • 怪了,我用了几个yahoo email,都不行。yahoo technical support 信誓旦旦的说行。我却怎么试都不行。付费免费的都不行。