测试smtp邮件连接
问题描述:
hi frnds !!!
i创建发送邮件的应用程序,在发送邮件之前我检查邮件ID和密码威胁测试连接。
如果电子邮件ID和密码组合不匹配,则在发送邮件之前给出消息。
Plz帮助!!!!
hi frnds!!!
i create application for send mail, before send mail i check email Id and password menace test connection.
if email Id and password combination is not match then give message before send mail.
Plz Help!!!!
答
内置-inSmtpClinet无法在发送邮件之前登录。 smtp协议本身支持多种身份验证方法。您可以提供密码的那个名为AUTH。请参阅有关某些方案的文章: http://www.samlogic.net/articles/smtp-commands -reference-auth.htm [ ^ 。正如您所看到的,有一些选项,但协议本身并不复杂,使用TcpClient实现它并不困难。您甚至可以使用原始的SmtpClient源,或在Web上查找其他实现。
The "built-in" SmtpClinet has no means to log in before sending mail. The smtp protocol itself supports several authentication methods. The one where you can provide password is called AUTH. See this article about some scenarios: http://www.samlogic.net/articles/smtp-commands-reference-auth.htm[^]. As you can see, there are some options, but the protocol itself is not complicated, it i not so hard to implement it with TcpClient. You can even make use of the original SmtpClient source, or look for other implementations on the web.
您好b $ b
你可能想要使用它:
Hi
you might want to use this:
//This is the code to send an email message from a console application in C#
MailMessage Email = new MailMessage();
Console.WriteLine("Sender:");
MailAddress Sender = new MailAddress(Console.ReadLine());
Email.From = Sender; // Set the sender of the email message
Console.WriteLine("To:");
Email.To.Add(Console.ReadLine()); // Email address which receives the email
Console.WriteLine("Subject:");
Email.Subject = Console.ReadLine(); // Add emailmessage subject
Console.WriteLine("Text:");
Email.Body = Console.ReadLine(); // email message text
Console.WriteLine("SMTP server:");
string ServerName = Console.ReadLine();//Get the SMTP server address
Console.WriteLine("Port:");
string Port = Console.ReadLine();//Get the port which is used by the SMTP server
SmtpClient MailClient = new SmtpClient(ServerName, int.Parse(Port)); //Create object for SMTP server connection, but no login yet
Console.WriteLine("Username:");
string UserName = Console.ReadLine();//Getting username for login on SMTP server
Console.WriteLine("Password:");
string Password = Console.ReadLine();//Getting password for SMTP login
System.Net.NetworkCredential Credentials = new System.Net.NetworkCredential(UserName, Password);//Create credentials object for login at smtp server
MailClient.Credentials = Credentials; //Add credentials to object for smtp server creation
MailClient.Send(Email); // Send email message. If login at the SMTP server was not possible an exception will be raised at this point.
欢呼,>
Marco Alessandro Bertschi
cheers,
Marco Alessandro Bertschi
Hii Friend
请改进您的问题,以帮助我们帮助您。
实际上你想用smtp做什么???
Hii Friend
please improve your question that can help us to help you.
what you actually want to do with smtp???