c# checker, how ?

Yeeted

Newbie
Joined
Jun 29, 2019
Messages
2
Reaction score
0
Hi guys. I'm interested in making windows applications with c#, but i'm bored with calculators and programs like that. I wonder how email checker are made? I searched on google but there is not to much info about that, or i dont know where and how to search. I read about some email librarys and some protocol. Is there any library just for that ? How to start with email checker ? Thanks for help :)
 
Hello bro. It easy to start. I am not very good known c# , but i make this scripts on python. Let's try to figure it out. If you want to read email you must use IMAP protocol, if you want send emails you must use SMTP protocol. Not all services allow autorize with imap without prescribed access rights in your email account.1) install package Spire.Email. 2) connect namespaces
using System;
using System.Globalization;
using Spire.Email;
using Spire.Email.IMap;
using Spire.Email.Smtp;

3) use this simple example, imap host and imap port is individual for each mail service. This information you cand find in google by writting a request "aol imap settings" or for example "gmail imap settings". You will see host and port. Write it's to solution.

  1. //Create an IMAP client
  2. ImapClient imap = new ImapClient();
  3. // Set host, username, password etc. for the client
  4. imap.Host = "outlook.office365.com";
  5. imap.Port = 143;
  6. imap.Username = "[email protected]";
  7. imap.Password = "password";
  8. imap.ConnectionProtocols = ConnectionProtocols.Ssl;
  9. //Connect the server
  10. imap.Connect();
  11. //Select Inbox folder
  12. imap.Select("Inbox");
  13. //Get the first message by its sequence number
  14. MailMessage message = imap.GetFullMessage(1);
  15. //Parse the message
  16. Console.WriteLine("------------------ HEADERS ---------------");
  17. Console.WriteLine("From : " + message.From.ToString());
  18. Console.WriteLine("To : " + message.To.ToString());
  19. Console.WriteLine("Date : " + message.Date.ToString(CultureInfo.InvariantCulture));
  20. Console.WriteLine("Subject: " + message.Subject);
  21. Console.WriteLine("------------------- BODY -----------------");
  22. Console.WriteLine(message.BodyText);
  23. Console.WriteLine("------------------- END ------------------");
  24. //Save the message to disk using its subject as file name
  25. message.Save(message.Subject + ".eml", MailMessageFormat.Eml);
  26. Console.WriteLine("Message Saved.");
 
Hello bro. It easy to start. I am not very good known c# , but i make this scripts on python. Let's try to figure it out. If you want to read email you must use IMAP protocol, if you want send emails you must use SMTP protocol. Not all services allow autorize with imap without prescribed access rights in your email account.1) install package Spire.Email. 2) connect namespaces
using System;
using System.Globalization;
using Spire.Email;
using Spire.Email.IMap;
using Spire.Email.Smtp;

3) use this simple example, imap host and imap port is individual for each mail service. This information you cand find in google by writting a request "aol imap settings" or for example "gmail imap settings". You will see host and port. Write it's to solution.
Its great that someone like you share the code so beginners like me can learn from that.
I am trying to build an email checker bot too. How we handle if the credentials is not just email/password but another recovery questions like phone number| recovery email?
 
Its great that someone like you share the code so beginners like me can learn from that.
I am trying to build an email checker bot too. How we handle if the credentials is not just email/password but another recovery questions like phone number| recovery email?

Using the smtp client and finding the credentials you need from the site of the email domain you're using.

Gmail for instance has certain certifications you have to include in your code to access an email on their server.
 
@Jibri Wright
Thanks for that man. I read some of your comments in IG sections and it really helps me too. :D
Does Smtp Client have any method supporting credentials with recovery email?
 
I am trying to check the credentials is right or wrong. Please check my pm. Really need your help

Its pretty simple if you have some experience with C#. There are a few free/open source libraries out there that are well documented. Let me know if you still need some help,Ill see what i can do in my free time.
 
Thanks for the reply. The hard part is it has three information in the credentials.
Email: Password : Recovery Email
Most of free libraries support Credentials with Email:Password only
 
Thanks for the reply. The hard part is it has three information in the credentials.
Email: Password : Recovery Email
Most of free libraries support Credentials with Email:password only
I have never had that issue.Are you trying 1 specific email provider or do most of them have this issue?
 
var dnsClient = new LookupClient(options);
try
{
var mxRecords = dnsClient.Query(mailAddress.Host, QueryType.MX)
.Answers
.MxRecords()
.ToList();

if (mxRecords.Count == 0)
{
result.Code = SmtpStatusCode.MailboxUnavailable;
result.Msg = "No email on the domain";
}

foreach (MxRecord mxRecord in mxRecords)
{
try
{
var smtpClient = new SmtpClient(mxRecord.Exchange.Value);
var response = smtpClient.CheckMailboxExists(email);
var state = response.Code == SmtpStatusCode.Ok || response.Code == SmtpStatusCode.ServiceClosingTransmissionChannel;
result.Msg = state ? string.Empty : response.Raw;
result.Code = response.Code;
result.IsValid = state ? true : false;
return result;
}
catch (SmtpClientException ex)
{
result.Msg = ex.Message;
break;
}
catch (ArgumentNullException ex)
{
result.Msg = ex.Message;
}
}
 
Back
Top