473,394 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

[c# winform] telnet, smtp server auth.

77
I've already got some code in place which allows me to connect to a smtp server and verify the ip(just checks for a timeout.). anyway, i now need the app to check that the user and password its given has access to the smtp to send email. the code i have is as follows.
Expand|Select|Wrap|Line Numbers
  1. public ScriptingTelnet(string Address, int Port, int CommandTimeout)
  2.         {
  3.             address = Address;
  4.             port = Port;
  5.             timeout = CommandTimeout;
  6.         }
  7.  
  8.  
  9. public bool Connect()
  10.         {
  11.             string []aliases;
  12.             IPAddress[] addr;
  13.             try
  14.             {
  15.                 IPHostEntry IPHost = Dns.Resolve(address); 
  16.                 aliases = IPHost.Aliases; 
  17.                 addr = IPHost.AddressList; 
  18.             }
  19.             catch
  20.             {
  21.                 return false;
  22.             }
  23.  
  24.             try
  25.             {
  26.                 // Try a blocking connection to the server
  27.                 s                = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
  28.                 iep                = new IPEndPoint(addr[0],port);  
  29.                 s.Connect(iep) ;    
  30.  
  31.  
  32.                 // If the connect worked, setup a callback to start listening for incoming data
  33.                 AsyncCallback recieveData = new AsyncCallback( OnRecievedData );
  34.                 s.BeginReceive( m_byBuff, 0, m_byBuff.Length, SocketFlags.None, recieveData , s );
  35.  
  36.                 // All is good
  37.                 return true;
  38.             }
  39.             catch
  40.             {
  41.                 // Something failed
  42.                 return false;
  43.             }
  44.  
  45.         }
  46.  
so to do my test i call something like:
Expand|Select|Wrap|Line Numbers
  1.             objActiveSolutions.ScriptingTelnet telnet = new objActiveSolutions.ScriptingTelnet(this.tbSMTPIP.Text, 25, 10);
  2.             if(telnet.Connect())
  3.             {
  4.                 //do something
  5.             }
  6.  

Anyone know who i can modify this to allow me to authenticate the user and pass?

Many Thanks,
Piercy
Oct 17 '07 #1
14 9124
Plater
7,872 Expert 4TB
If you are talking to the SMTP server, look up the SMTP commands.
Giving the "EHLO <your computer identity>"+[enter] should give you a response back telling you what AUTH types are available.
You can then send the correct sequence of commands to AUTH the user.

The rfc for the AUTH command extension can be found here
Oct 17 '07 #2
piercy
77
If you are talking to the SMTP server, look up the SMTP commands.
Giving the "EHLO <your computer identity>"+[enter] should give you a response back telling you what AUTH types are available.
You can then send the correct sequence of commands to AUTH the user.

The rfc for the AUTH command extension can be found here
yes, i know the commands i need to use or i cna look them up. but im just not sure how i would send the commands to the server from the program.

im basically doing a check for a smtp server, my users use the application to send emails to people in a database.

now on settings up the app they admin will need to put in the smtp ip, username and password if required. the code i have above check the ip address responds. now i need it to authenticate and check it responds at the same time.

any ideas on how to send the commands from the app? just and ehlo or something then i can work out the auth and stuff myself.

Thanks once again,
Piercy
Oct 17 '07 #3
Plater
7,872 Expert 4TB
In the program I made for smtp, I had an active socket connection the smtp server. (I presume that this is a real smtp server yes?)
On the socket I send the commands as ASCII strings

Format of EHLO:
Expand|Select|Wrap|Line Numbers
  1. string computername="PlaterComputer";
  2. string domainname="mydomain.com";
  3. string ehlostring= "EHLO "+computername+"."+domainname+"\r\n";
  4.  
Then the response back should follow the SMPT standards. It's possible the server will NOT list the available ATUH types (I believe it is supposed to though)

That link I send in the past message has example communications, i.e.:
C: EHLO mycomputer.mydomain.com
S: 250-mail.mydomain.com
S: 250 AUTH CRAM-MD5 DIGEST-MD5
That server will accept CRAM-MD5 and DIGEST-MD5 auth types.

Was that what you were looking for or were you looking for the actual how to send it using code thing?
Oct 17 '07 #4
piercy
77
In the program I made for smtp, I had an active socket connection the smtp server. (I presume that this is a real smtp server yes?)
On the socket I send the commands as ASCII strings

Format of EHLO:
Expand|Select|Wrap|Line Numbers
  1. string computername="PlaterComputer";
  2. string domainname="mydomain.com";
  3. string ehlostring= "EHLO "+computername+"."+domainname+"\r\n";
  4.  
Then the response back should follow the SMPT standards. It's possible the server will NOT list the available ATUH types (I believe it is supposed to though)

That link I send in the past message has example communications, i.e.:

That server will accept CRAM-MD5 and DIGEST-MD5 auth types.

Was that what you were looking for or were you looking for the actual how to send it using code thing?

It doesn thave to use the code i provided. it would just be helpful if it did. im playing around with it now and the smtp server im using (yes it's real)
Expand|Select|Wrap|Line Numbers
  1. 250 - AUTH GSSAPI NTLM LOGIN
  2. 250 - AUTH =LOGIN
  3.  
thats part of what my server responds when ehlo it using cmd prmpt.

would you be able to give me the exact piece of code to send to the server. ie, i think the coding im using does this...

Socket s = new socket........
so the how would i send the commands soemthing like s.command?
Oct 17 '07 #5
Plater
7,872 Expert 4TB
250 - AUTH GSSAPI NTLM LOGIN
250 - AUTH =LOGIN

So your server would prefer that use "LOGIN", but allows those other two types as well.

Well once you have you Socket created and connected (You can use the TcpClient object if you prefer)
So consider the following:
I have a function:
Expand|Select|Wrap|Line Numbers
  1. private void Write(TcpClient tcpc, byte[] buff)
  2.         {
  3.             try
  4.             {
  5.                 tcpc.GetStream().Write(buff, 0, buff.Length);
  6.             }
  7.             catch (IOException ioe)
  8.             {
  9.                 bool ignoreme = (ioe.Message == "");
  10.                 tcpc.Close();
  11.             }
  12.             catch (SocketException se)
  13.             {
  14.                 bool ignoreme = (se.Message == "");
  15.                 tcpc.Close();
  16.             }
  17.         }
  18.  
Then I could use:
Expand|Select|Wrap|Line Numbers
  1. string authstring="AUTH LOGIN\r\n";
  2. byte[] authbytes=Encoding.ASCII.GetBytes(authstring);
  3. //you need a byte[] to send on the socket
  4. // Encoding.ASCII is your friend
  5.  
  6. write(mytcpclient, authbytes);//send the command string
  7.  
  8. //you will then have to wait and read the response back
  9. //my actual "read" function used to read the response is pretty big
  10. //but I will include a little bit to get you started maybe:
  11. private string GetResponse(TcpClient tcpc)
  12. {
  13.    string gotin = "";
  14.    while (tcpc.GetStream().DataAvailable)
  15.    {
  16.       gotin += ((char)tcpc.GetStream().ReadByte());
  17.    }
  18.    return gotin;
  19. }
  20.  
You would then use the write/read functions to send you commands and verify the response.
Oct 17 '07 #6
piercy
77
250 - AUTH GSSAPI NTLM LOGIN
250 - AUTH =LOGIN

So your server would prefer that use "LOGIN", but allows those other two types as well.

Well once you have you Socket created and connected (You can use the TcpClient object if you prefer)
So consider the following:
I have a function:
Expand|Select|Wrap|Line Numbers
  1. private void Write(TcpClient tcpc, byte[] buff)
  2.         {
  3.             try
  4.             {
  5.                 tcpc.GetStream().Write(buff, 0, buff.Length);
  6.             }
  7.             catch (IOException ioe)
  8.             {
  9.                 bool ignoreme = (ioe.Message == "");
  10.                 tcpc.Close();
  11.             }
  12.             catch (SocketException se)
  13.             {
  14.                 bool ignoreme = (se.Message == "");
  15.                 tcpc.Close();
  16.             }
  17.         }
  18.  
Then I could use:
Expand|Select|Wrap|Line Numbers
  1. string authstring="AUTH LOGIN\r\n";
  2. byte[] authbytes=Encoding.ASCII.GetBytes(authstring);
  3. //you need a byte[] to send on the socket
  4. // Encoding.ASCII is your friend
  5.  
  6. write(mytcpclient, authbytes);//send the command string
  7.  
  8. //you will then have to wait and read the response back
  9. //my actual "read" function used to read the response is pretty big
  10. //but I will include a little bit to get you started maybe:
  11. private string GetResponse(TcpClient tcpc)
  12. {
  13.    string gotin = "";
  14.    while (tcpc.GetStream().DataAvailable)
  15.    {
  16.       gotin += ((char)tcpc.GetStream().ReadByte());
  17.    }
  18.    return gotin;
  19. }
  20.  
You would then use the write/read functions to send you commands and verify the response.

right, im feeling like an idiot at the moment... lol... anyway, this is the code i had and it seems to contain all the information i need.. not definate but i think it does.

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Net;
  3. using System.Net.Sockets;
  4. using System.Text;
  5. using System.IO;
  6. using System.Threading ;
  7.  
  8. namespace objActiveSolutions
  9. {
  10.     /// <summary>
  11.     /// Summary description for clsScriptingTelnet.
  12.     /// </summary>
  13.     public class ScriptingTelnet
  14.     {
  15.         private IPEndPoint iep ;
  16.         private AsyncCallback callbackProc;
  17.         private string address ;
  18.         private int port ;
  19.         private int timeout;
  20.         private Socket s ;
  21.         Byte[] m_byBuff = new Byte[32767];
  22.         private string strWorkingData = "";                    // Holds everything received from the server since our last processing
  23.         private string strFullLog = "";
  24.  
  25.         public ScriptingTelnet(string Address, int Port, int CommandTimeout)
  26.         {
  27.             address = Address;
  28.             port = Port;
  29.             timeout = CommandTimeout;
  30.         }
  31.  
  32.  
  33.         private void OnRecievedData( IAsyncResult ar )
  34.         {
  35.             // Get The connection socket from the callback
  36.             Socket sock = (Socket)ar.AsyncState;
  37.  
  38.             // Get The data , if any
  39.             int nBytesRec = sock.EndReceive( ar );        
  40.  
  41.             if( nBytesRec > 0 )
  42.             {
  43.                 // Decode the received data
  44.                 string sRecieved = CleanDisplay(Encoding.ASCII.GetString( m_byBuff, 0, nBytesRec ));
  45.  
  46.                 // Write out the data
  47.                 if (sRecieved.IndexOf("[c") != -1) Negotiate(1);
  48.                 if (sRecieved.IndexOf("[6n") != -1) Negotiate(2);
  49.  
  50.                 Console.WriteLine(sRecieved);
  51.                 strWorkingData += sRecieved;
  52.                 strFullLog += sRecieved;
  53.  
  54.  
  55.                 // Launch another callback to listen for data
  56.                 AsyncCallback recieveData = new AsyncCallback(OnRecievedData);
  57.                 sock.BeginReceive( m_byBuff, 0, m_byBuff.Length, SocketFlags.None, recieveData , sock );
  58.  
  59.             }
  60.             else
  61.             {
  62.                 // If no data was recieved then the connection is probably dead
  63.                 Console.WriteLine( "Disconnected", sock.RemoteEndPoint );
  64.                 sock.Shutdown( SocketShutdown.Both );
  65.                 sock.Close();
  66.                 //Application.Exit();
  67.             }
  68.         }
  69.  
  70.         private void DoSend(string strText)
  71.         {
  72.             try
  73.             {
  74.                 Byte[] smk = new Byte[strText.Length];
  75.                 for ( int i=0; i < strText.Length ; i++)
  76.                 {
  77.                     Byte ss = Convert.ToByte(strText[i]);
  78.                     smk[i] = ss ;
  79.                 }
  80.  
  81.                 s.Send(smk,0 , smk.Length , SocketFlags.None);
  82.             }
  83.             catch
  84.             {
  85.                 //MessageBox.Show("ERROR IN RESPOND OPTIONS");
  86.             }
  87.         }
  88.  
  89.         private void Negotiate(int WhichPart)
  90.         {
  91.             StringBuilder x;
  92.             string neg;
  93.             if (WhichPart == 1)
  94.             {
  95.                 x = new StringBuilder();
  96.                 x.Append ((char)27);
  97.                 x.Append ((char)91);
  98.                 x.Append ((char)63);
  99.                 x.Append ((char)49);
  100.                 x.Append ((char)59);
  101.                 x.Append ((char)50);
  102.                 x.Append ((char)99);
  103.                 neg =  x.ToString();
  104.             }
  105.             else
  106.             {
  107.  
  108.                 x = new StringBuilder();
  109.                 x.Append ((char)27);
  110.                 x.Append ((char)91);
  111.                 x.Append ((char)50);
  112.                 x.Append ((char)52);
  113.                 x.Append ((char)59);
  114.                 x.Append ((char)56);
  115.                 x.Append ((char)48);
  116.                 x.Append ((char)82);
  117.                 neg = x.ToString();
  118.             }
  119.             SendMessage(neg,true);
  120.         }
  121.  
  122.         private string CleanDisplay(string input)
  123.         {
  124.  
  125.             input = input.Replace("(0x (B","|");
  126.             input = input.Replace("(0 x(B","|");
  127.             input = input.Replace(")0=>","");
  128.             input = input.Replace(">","");
  129.             input = input.Replace("7","[");
  130.             input = input.Replace("*8","]");
  131.             input = input.Replace("","");
  132.             return input;
  133.         }
  134.  
  135.  
  136.  
  137.  
  138.         /// <summary>
  139.         /// Connects to the telnet server.
  140.         /// </summary>
  141.         /// <returns>True upon connection, False if connection fails</returns>
  142.         public bool Connect()
  143.         {
  144.             string []aliases;
  145.             IPAddress[] addr;
  146.             try
  147.             {
  148.                 IPHostEntry IPHost = Dns.Resolve(address); 
  149.                 aliases = IPHost.Aliases; 
  150.                 addr = IPHost.AddressList; 
  151.             }
  152.             catch
  153.             {
  154.                 return false;
  155.             }
  156.  
  157.             try
  158.             {
  159.                 // Try a blocking connection to the server
  160.                 s                = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
  161.                 iep                = new IPEndPoint(addr[0],port);  
  162.                 s.Connect(iep) ;    
  163.  
  164.  
  165.                 // If the connect worked, setup a callback to start listening for incoming data
  166.                 AsyncCallback recieveData = new AsyncCallback( OnRecievedData );
  167.                 s.BeginReceive( m_byBuff, 0, m_byBuff.Length, SocketFlags.None, recieveData , s );
  168.  
  169.                 // All is good
  170.                 return true;
  171.             }
  172.             catch
  173.             {
  174.                 // Something failed
  175.                 return false;
  176.             }
  177.  
  178.         }
  179.  
  180.  
  181.         public void Disconnect()
  182.         {
  183.             if (s.Connected) s.Close();
  184.         }
  185.  
  186.         /// <summary>
  187.         /// Waits for a specific string to be found in the stream from the server
  188.         /// </summary>
  189.         /// <param name="DataToWaitFor">The string to wait for</param>
  190.         /// <returns>Always returns 0 once the string has been found</returns>
  191.         public int WaitFor(string DataToWaitFor)
  192.         {
  193.             // Get the starting time
  194.             long lngStart = DateTime.Now.AddSeconds(this.timeout).Ticks;
  195.             long lngCurTime = 0;
  196.  
  197.             while (strWorkingData.ToLower().IndexOf(DataToWaitFor.ToLower()) == -1)
  198.             {
  199.                 // Timeout logic
  200.                 lngCurTime = DateTime.Now.Ticks;
  201.                 if (lngCurTime > lngStart)
  202.                 {
  203.                     throw new Exception("Timed Out waiting for : " + DataToWaitFor);
  204.                 }
  205.                 Thread.Sleep(1);
  206.             }
  207.             strWorkingData = "";
  208.             return 0;
  209.         }
  210.  
  211.  
  212.         /// <summary>
  213.         /// Waits for one of several possible strings to be found in the stream from the server
  214.         /// </summary>
  215.         /// <param name="DataToWaitFor">A delimited list of strings to wait for</param>
  216.         /// <param name="BreakCharacters">The character to break the delimited string with</param>
  217.         /// <returns>The index (zero based) of the value in the delimited list which was matched</returns>
  218.         public int WaitFor(string DataToWaitFor,string BreakCharacter)
  219.         {
  220.             // Get the starting time
  221.             long lngStart = DateTime.Now.AddSeconds(this.timeout).Ticks;
  222.             long lngCurTime = 0;
  223.  
  224.             string[] Breaks = DataToWaitFor.Split(BreakCharacter.ToCharArray());
  225.             int intReturn = -1;
  226.  
  227.             while (intReturn == -1)
  228.             {
  229.                 // Timeout logic
  230.                 lngCurTime = DateTime.Now.Ticks;
  231.                 if (lngCurTime > lngStart)
  232.                 {
  233.                     throw new Exception("Timed Out waiting for : " + DataToWaitFor);
  234.                 }
  235.  
  236.                 Thread.Sleep(1);
  237.                 for (int i = 0 ; i < Breaks.Length ; i++)
  238.                 {
  239.                     if (strWorkingData.ToLower().IndexOf(Breaks[i].ToLower()) != -1)
  240.                     {
  241.                         intReturn = i ;
  242.                     }
  243.                 }
  244.             }
  245.             return intReturn;
  246.  
  247.         }
  248.  
  249.  
  250.         /// <summary>
  251.         /// Sends a message to the server
  252.         /// </summary>
  253.         /// <param name="Message">The message to send to the server</param>
  254.         /// <param name="SuppressCarriageReturn">True if you do not want to end the message with a carriage return</param>
  255.         public void SendMessage(string Message, bool SuppressCarriageReturn)
  256.         {
  257.             strFullLog += "\r\nSENDING DATA ====> " + Message.ToUpper() + "\r\n";
  258.             Console.WriteLine("SENDING DATA ====> " + Message.ToUpper());
  259.  
  260.             if (! SuppressCarriageReturn)
  261.             {
  262.                 DoSend(Message + "\r");
  263.             }
  264.             else
  265.             {
  266.                 DoSend(Message);
  267.             }
  268.         }
  269.  
  270.  
  271.         /// <summary>
  272.         /// Sends a message to the server, automatically appending a carriage return to it
  273.         /// </summary>
  274.         /// <param name="Message">The message to send to the server</param>
  275.         public void SendMessage(string Message)
  276.         {
  277.             strFullLog += "\r\nSENDING DATA ====> " + Message.ToUpper() + "\r\n";
  278.             Console.WriteLine("SENDING DATA ====> " + Message.ToUpper());
  279.  
  280.             DoSend(Message + "\r");
  281.         }
  282.  
  283.  
  284.         /// <summary>
  285.         /// Waits for a specific string to be found in the stream from the server.
  286.         /// Once that string is found, sends a message to the server
  287.         /// </summary>
  288.         /// <param name="WaitFor">The string to be found in the server stream</param>
  289.         /// <param name="Message">The message to send to the server</param>
  290.         /// <returns>Returns true once the string has been found, and the message has been sent</returns>
  291.         public void WaitAndSend(string WaitFor,string Message)
  292.         {
  293.             this.WaitFor(WaitFor);
  294.             SendMessage(Message);
  295.  
  296.  
  297.         }
  298.  
  299.  
  300.         /// <summary>
  301.         /// Sends a message to the server, and waits until the designated
  302.         /// response is received
  303.         /// </summary>
  304.         /// <param name="Message">The message to send to the server</param>
  305.         /// <param name="WaitFor">The response to wait for</param>
  306.         /// <returns>True if the process was successful</returns>
  307.         public string SendAndWait(string Message, string WaitFor)
  308.         {
  309.  
  310.             SendMessage(Message);
  311.             this.WaitFor(WaitFor);
  312.             return strWorkingData;
  313.         }
  314.  
  315.  
  316.  
  317.         public int SendAndWait(string Message, string WaitFor, string BreakCharacter)
  318.         {
  319.             SendMessage(Message);
  320.             int t = this.WaitFor(WaitFor,BreakCharacter);
  321.             return t;
  322.         }
  323.  
  324.  
  325.         /// <summary>
  326.         /// A full log of session activity
  327.         /// </summary>
  328.         public string SessionLog
  329.         {
  330.             get 
  331.             {
  332.                 return strFullLog;
  333.             }
  334.         }
  335.  
  336.  
  337.         /// <summary>
  338.         /// Clears all data in the session log
  339.         /// </summary>
  340.         public void ClearSessionLog()
  341.         {
  342.             strFullLog = "";
  343.         }
  344.  
  345.  
  346.         /// <summary>
  347.         /// Searches for two strings in the session log, and if both are found, returns
  348.         /// all the data between them.
  349.         /// </summary>
  350.         /// <param name="StartingString">The first string to find</param>
  351.         /// <param name="EndingString">The second string to find</param>
  352.         /// <param name="ReturnIfNotFound">The string to be returned if a match is not found</param>
  353.         /// <returns>All the data between the end of the starting string and the beginning of the end string</returns>
  354.         public string FindStringBetween(string StartingString, string EndingString, string ReturnIfNotFound)
  355.         {
  356.             int intStart;
  357.             int intEnd;
  358.  
  359.             intStart = strFullLog.ToLower().IndexOf(StartingString.ToLower());
  360.             if (intStart == -1)
  361.             {
  362.                 return ReturnIfNotFound;
  363.             }
  364.             intStart += StartingString.Length;
  365.  
  366.             intEnd = strFullLog.ToLower().IndexOf(EndingString.ToLower(),intStart);
  367.  
  368.             if (intEnd == -1)
  369.             {
  370.                 // The string was not found
  371.                 return ReturnIfNotFound;
  372.             }
  373.  
  374.             // The string was found, let's clean it up and return it
  375.             return strFullLog.Substring(intStart, intEnd-intStart).Trim();
  376.         }
  377.  
  378.  
  379.     }
  380. }
  381.  
  382.  
i know this is a lot of code to paste, i did look for a online code dump to make it easier but couldnt find one.

would you be able to give me a quick example (using this if you can) on how to AUTH to a server preferably in the login encoding and/or a way to check for the auth the server requires and auth usign that(because thats the eventual need).

Thanks you very much, youve been a big help... even though i havent got my result yet im undertsanding it alot more.

Thanks,
Piercy
Oct 17 '07 #7
Plater
7,872 Expert 4TB
Well I think you can do this:
Expand|Select|Wrap|Line Numbers
  1. string authstart="AUTH LOGIN\r\n";
  2. SendMessage(authstart,true);
  3. //you need a "\r\n" I think, maybe not, whatever though
  4.  
Now the problem is, you don't know what the response will be that you're waiting for, other then it will start with a 3-digit number and end with a "\r" or "\r\n".

It didn't look like you had a way to read a response and process it. The AUTH types require you to examine the reply to determine your response.

Appendix B: A LOGIN SMTP AUTH Conversation
A LOGIN SMTP Authentication conversation looks something like the following (after the mail server has indicated its support for the LOGIN mechanism):


C: AUTH LOGIN
S: 334 VXNlcm5hbWU6
C: d2VsZG9u
S: 334 UGFzc3dvcmQ6
C: dzNsZDBu
S: 235 2.0.0 OK Authenticated

Lines 2-5 of the conversation contain base64-encoded information. The same conversation, with base64 strings decoded, reads:


C: AUTH LOGIN
S: 334 Username:
C: weldon
S: 334 Password:
C: w3ld0n
S: 235 2.0.0 OK Authenticated
And the Convert object has .ToBase64String() ability for you.
Oct 17 '07 #8
piercy
77
Well I think you can do this:
Expand|Select|Wrap|Line Numbers
  1. string authstart="AUTH LOGIN\r\n";
  2. SendMessage(authstart,true);
  3. //you need a "\r\n" I think, maybe not, whatever though
  4.  
Now the problem is, you don't know what the response will be that you're waiting for, other then it will start with a 3-digit number and end with a "\r" or "\r\n".

It didn't look like you had a way to read a response and process it. The AUTH types require you to examine the reply to determine your response.



And the Convert object has .ToBase64String() ability for you.
you still need to use the econding .ascii.getbytes because Convet.ToBase64String needs it in byte[] form. anyway, thats a greta help. tells em what to do really well. im still stuck with how i verify that connection. after all thats what its all about. some sort fo command i would need to be auth for for it to work? would i still need to be abel to return something from the server to verify the conenction?

or any other possible ways to verify the username and password against the ipaddress?
Oct 17 '07 #9
Plater
7,872 Expert 4TB
Some servers have a VRFY command, but it's been my experiance that very few implement it.

Other than connecting to the smtp server and running the AUTH command sequence, I don't know of any way to validate username and passwords against a mail server.
Oct 17 '07 #10
piercy
77
Some servers have a VRFY command, but it's been my experiance that very few implement it.

Other than connecting to the smtp server and running the AUTH command sequence, I don't know of any way to validate username and passwords against a mail server.

ok, looks like my client will have to go without the verification feature. ill verify theres a smtp server there then its there own job to make sure they give my the correct username and password.

Thanks very much for your help. even though id dint get the result i wanted i learnt a lot while doing it.

Thanks once again,
Piercy
Oct 17 '07 #11
Plater
7,872 Expert 4TB
Are you not allowed to modify the code you provided to me?
It might be possible for you to simple "add in" the response reading functions that you need.
Oct 17 '07 #12
piercy
77
Are you not allowed to modify the code you provided to me?
It might be possible for you to simple "add in" the response reading functions that you need.
i can modify it all i wish. also, the s3xy person next to me(lol).. recomended calling a hidden command prompt using the system.diagnostics namespace.

have you got any ideas for modifying that code then?

THanks,
Piercy
Oct 17 '07 #13
Plater
7,872 Expert 4TB
Well what you would need is a "readline" from the response stream.and then have access to everything up till that point.
All server responses start with 3digits and end with the newline terminator.
If you could find a way to get at that it might work.
Oct 17 '07 #14
piercy
77
edit: going to post ina enw thread as its a totally different problem now.. thanks for your help.
Oct 23 '07 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Dan | last post by:
I'm writing a simplistic telnet client in VB6 and I've run into a small snag. The program has a textbox to write in the string to be sent using ..SendData and has another textbox that displays...
2
by: Mark Carter | last post by:
I'm trying to create a mail server in Twisted. I either get SMTPSenderRefused or SMTPException: SMTP AUTH extension not supported by server. What do I need to do to get it to work?
1
by: David Hughes | last post by:
I wonder if anyone can help me resolve this problem. Although my ISP (One and One) provides the facility to run Python 2.2 CGI programs, their technical support people don't seem to have any Python...
4
by: LutherRevisited | last post by:
Ok with some tweaking I got it to where I could send through my local isp's smtp server, but I am restricted to sending the message from my ISP's mail account. When I respond to Yahoo mail, I want...
0
by: LutherRevisited | last post by:
To clear up something which Gerhard advised me on regarding the login method. I've found that AOL's smtp server is unique compared to every other one I've seen. If you type auth plain, it will...
4
by: z f | last post by:
Hi, i'm sending mail from the aspx page on the server. it is running on hosting, so i configure the System.Web.Mail.SmtpMail.SmtpServer property to my mail server. but problem is that sender...
1
by: the_ricka | last post by:
Hi all, I'm fairly new to python, but very excited about it's potential. I'm trying to write a simple program that will accept input from a command line and send email. The parameters I used on...
1
by: Jeff | last post by:
I am receiving the following error: // error: System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 No...
7
by: John Drako | last post by:
Currently, I run postfix on my own server to send message from my site (password requests, account activation notices and other messages). I have phpMailer on the server and all the messages...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.