Пример #1
0
 private static void WaitForMailsToReach(TempMailClient client, int mailsCount, int delay = 1000)
 {
     while (client.Inbox.Mails.Count < mailsCount)
     {
         Thread.Sleep(delay);
     }
 }
        public static async Task SampleWithProxy()
        {
            var client = TempMailClient.Create(
                proxy: new WebProxy("163.172.220.221", 8888));

            await Sample(client);
        }
Пример #3
0
        public static Mail FromId(TempMailClient session, string id)
        {
            var sourceUrl = $"{ConstantsUrL.URL_SOURCE}{id}";
            var mailRaw   = session.client.GetString(sourceUrl);

            return(GetMailFromRaw(mailRaw, id));
        }
Пример #4
0
        public static void SampleWithProxy()
        {
            var client = TempMailClient.Create(
                proxy: new WebProxy("163.172.220.221", 8888));

            Sample(client);
        }
Пример #5
0
        static void Main(string[] args)
        {
            // To get a new temporary email
            var tempMail = new TempMailClient();

            // To get all available domains
            var domains = tempMail.AvailableDomains;

            // To get Mailbox
            var mails = tempMail.GetMails();

            // To change email to a specific login@domain
            tempMail.ChangeEmail("loginexample", domains[0]);

            // To get a new temporary email with a specific login@domain
            tempMail = new TempMailClient("loginexample", domains[0]);

            // To get a new temporary email with with login and random domain
            tempMail = new TempMailClient("loginexample");

            // To delete current email and get a new one
            tempMail.Delete();

            // To get the current email account
            string email = tempMail.Email;
        }
 private static async Task WaitForMailsToReach(TempMailClient client, int mailsCount, int delay = 1000)
 {
     while (client.Inbox.Mails.Count < mailsCount)
     {
         await Task.Delay(delay);
     }
 }
        public static async Task SampleWithCaptchaProviderAndProxy()
        {
            var client = TempMailClient.Create(
                captchaProvider: new AntiCaptchaProvider("YOUR_API_KEY"),
                proxy: new WebProxy("163.172.220.221", 8888));

            await Sample(client);
        }
        public static async Task SampleWithCaptchaProvider()
        {
            // Used if temp-mail is using cloudflare protection and it's not solved with JS (if needed).
            var client = TempMailClient.Create(
                captchaProvider: new AntiCaptchaProvider("YOUR_API_KEY"));

            await Sample(client);
        }
Пример #9
0
        public void TestRefresh()
        {
            var client = TempMailClient.Create();

            var mails = client.Inbox.Refresh();

            Assert.AreSame(mails, client.Inbox.Mails);
        }
Пример #10
0
        public static Mail FromLink(TempMailClient session, string link)
        {
            var id        = Functions.GetMailIDFromLink(link);
            var sourceUrl = $"{ConstantsUrL.URL_SOURCE}{id}";
            var mailRaw   = session.client.GetString(sourceUrl);

            return(GetMailFromRaw(mailRaw, id));
        }
Пример #11
0
 public static void PrintClientData(TempMailClient client)
 {
     Console.WriteLine("========================================");
     Console.WriteLine($"Email: {client.Email}");
     Console.WriteLine("Inbox:");
     client.Inbox.Mails.ForEach(PrintMail);
     Console.WriteLine("========================================");
 }
Пример #12
0
        public async Task TestRefreshAsync()
        {
            var client = await TempMailClient.CreateAsync();

            var mails = await client.Inbox.RefreshAsync();

            Assert.AreSame(mails, client.Inbox.Mails);
        }
        public static async Task Sample(TempMailClient client)
        {
            // To get the available domains
            var availableDomains = client.AvailableDomains;

            // To get the current email
            var email = client.Email;

            client.EmailChanged          += (o, e) => Console.WriteLine($"Email changed: {e.Email}");
            client.Inbox.NewMailReceived += (o, e) => Common.PrintMail(e.Mail);

            // Sends fake mails from your email to generated temporary email
            // Note: edit sender email credentials (email, password)
            // Note: you can use any free email sender service online instead
            await Common.SendFakeMailsAsync(2, client.Email, 1000);

            // Checks for incoming mails every period of time
            client.StartAutoCheck();

            // Wait for the mails to reach the temp-mail
            await WaitForMailsToReach(client, 2, 1000);

            await Common.SendFakeMailsAsync(1, client.Email, 1000);

            await WaitForMailsToReach(client, 3, 1000);

            client.StopAutoCheck();

            // give it 10s delay to make sure it reached temp-mail
            await Common.SendFakeMailsAsync(1, client.Email, 10000, true);

            // Prints client session data like current email, mails, ...etc
            // Note: edit to print what you need
            Console.WriteLine("Only 3 mails, as we stopped auto check so we need to explicitly use refresh");
            Common.PrintClientData(client);

            // To get all mails in mailbox
            await client.Inbox.RefreshAsync();

            // To access mails
            var mails = client.Inbox.Mails;

            Console.WriteLine("4 mails (all mails)");
            Common.PrintClientData(client);

            // To save attachments
            mails.ForEach(mail => mail.SaveAttachments());

            // To change email to a specific login@domain
            await client.ChangeEmailAsync("loginexample", availableDomains[0]);

            // To delete email and get a new one
            await client.DeleteAsync();
        }
        public static async Task Sample()
        {
            var client = await TempMailClient.CreateAsync();

            await Sample(client);
        }
Пример #15
0
 public static async Task Initialize(TestContext context)
 {
     client = await TempMailClient.CreateAsync();
 }
Пример #16
0
 public static void Initialize(TestContext context)
 {
     client = TempMailClient.Create();
 }
Пример #17
0
        public static void Sample()
        {
            var client = TempMailClient.Create();

            Sample(client);
        }
Пример #18
0
        public void TestMails()
        {
            var client = TempMailClient.Create();

            Assert.IsNotNull(client.Inbox.Mails);
        }