日期:2014-05-19  浏览次数:20870 次

C#邮件发送程序提示错误“551, delivery not allowed to non-local recipient”
请问各位:
        我用C#写的邮件发送程序,现在总是提示“551,   delivery   not   allowed   to   non-local   recipient”,请问该如何解决?兄弟用的是Socket方式,发送部分代码如下:
try
{
tc=new   TcpClient(smtpServer,25);
}
catch   (Exception   e)
{
tc.Close();
return   "network   error ";
}


ns   =   tc.GetStream();

string[]   SendBuffer;
string   SendBufferstr;

SendBuffer=new   String[4];
SendBuffer[0]= "EHLO   "   +   smtpServer   +   enter;
SendBuffer[1]= "AUTH   LOGIN "   +   enter;
SendBuffer[2]=Base64Encode( "test@test.com ")   +   enter;
SendBuffer[3]=Base64Encode( "abcd ")   +   enter;

byte[]   WriteBuffer;
WriteBuffer   =   Encoding.Default.GetBytes(SendBuffer[0]);
try
{
ns.Write(WriteBuffer,0,WriteBuffer.Length);
}
catch
{
return   "Write   wrong   one ";

}

int   StreamSize;
string   ReturnValue   =   String.Empty;
byte[]   ReadBuffer   =   new   byte[1024]   ;
try
{
StreamSize=ns.Read(ReadBuffer,0,ReadBuffer.Length);
}
catch
{
return   "Read   wrong   one ";
}

if   (StreamSize==0)
{
// return   "0 ";
}
else
{
ReturnValue   =   Encoding.Default.GetString(ReadBuffer).Substring(0,StreamSize);
// return   ReturnValue;
}

WriteBuffer   =   Encoding.Default.GetBytes(SendBuffer[1]);
try
{
ns.Write(WriteBuffer,0,WriteBuffer.Length);
}
catch
{
return   "Write   wrong   two ";

}

try
{
StreamSize=ns.Read(ReadBuffer,0,ReadBuffer.Length);
}
catch
{
return   "Read   wrong   two ";
}

if   (StreamSize==0)
{
// return   "0 ";
}
else
{
ReturnValue   =   Encoding.Default.GetString(ReadBuffer).Substring(0,StreamSize);
// return   ReturnValue;
}

WriteBuffer   =   Encoding.Default.GetBytes(SendBuffer[2]);
try
{
ns.Write(WriteBuffer,0,WriteBuffer.Length);
}
catch
{
return   "Write   wrong   three ";

}

try
{
StreamSize=ns.Read(ReadBuffer,0,ReadBuffer.Length);
}
catch
{
return   "Read   wrong   three ";
}

if   (StreamSize==0)
{
// return   "0 ";
}
else
{
ReturnValue   =   Encoding.Default.GetString(ReadBuffer).Substring(0,StreamSize);
// return   ReturnValue;
}

WriteBuffer   =   Encoding.Default.GetBytes(SendBuffer[3]);
try
{
ns.Write(WriteBuffer,0,WriteBuffer.Length);
}
catch
{
return   "Write   wrong   four ";