public void ServerCanRunOnDifferentPort() { // Server is already running. We check that this cause an SocketException to be thrown var alternateServer = SimpleSmtpServer.Start(ALT_PORT); alternateServer.Stop(); }
public ForgotPasswordPage(FluentTest test) : base(test) { Url = TargetEnvironment.GetApplicationUrl("/#/forgot-password"); At = () => I.Expect.Exists(EmailInput); _server = SimpleSmtpServer.Start(25); }
public void MultipleServerPortSimple() { int ALT_PORT = 2525; // Start second server server2 = SimpleSmtpServer.Start(ALT_PORT); // Send to first server System.Web.Mail.SmtpMail.SmtpServer = "localhost"; System.Web.Mail.SmtpMail.Send("*****@*****.**", "*****@*****.**", "This is the subject", "This is the body."); // Check first server Assert.AreEqual(1, server.ReceivedEmail.Length, "server.ReceivedEmail.Length"); Assert.AreEqual(1, server.ReceivedEmailCount, "server.ReceivedEmailSize"); SmtpMessage email = server.ReceivedEmail[0]; Assert.AreEqual("<*****@*****.**>", email.Headers["To"]); Assert.AreEqual("<*****@*****.**>", email.Headers["From"]); Assert.AreEqual("text/plain;", email.Headers["Content-Type"]); Assert.AreEqual("This is the subject", email.Headers["Subject"]); Assert.AreEqual("This is the body.", email.Body); // Check second server Assert.AreEqual(0, server2.ReceivedEmail.Length, "server.ReceivedEmail.Length"); Assert.AreEqual(0, server2.ReceivedEmailCount, "server.ReceivedEmailSize"); }
public void Setup() { // NB Use port configured in App.config var client = new SmtpClient(); smtpServer = SimpleSmtpServer.Start(client.Port); }
public void Start_Server_Random_Port() { SimpleSmtpServer randomPortServer = this.StartServer(); Assert.True(randomPortServer.Configuration.Port > 0); randomPortServer.Stop(); }
public void ServerBindingError() { // Server is already running. We check that this cause an SocketException to be thrown SimpleSmtpServer.Start(TEST_ALT_PORT); Assert.Fail("BindingError"); }
public void SetUp() { _simpleSmtpServer = SimpleSmtpServer.Start(25); Environment.SetEnvironmentVariable("Host", "localhost"); Environment.SetEnvironmentVariable("Port", "25"); new SmtpMailer(); }
public void Setup() { // Create an SMTP client to get the port specified in app.config SmtpClient client = new SmtpClient(); _server = SimpleSmtpServer.Start(client.Port); }
public void WhenUsingHeaders_ThenHeadersReturned() { using (var client = new SmtpClient { Host = "localhost", Port = 25 }) { var msg = new MailMessage("*****@*****.**", "*****@*****.**", "some subject", "some body"); msg.Headers.Add("foo", "bar"); client.Send(msg); } int waitLoopCount = 0; var smtpServer = SimpleSmtpServer.Start(25); while (smtpServer.ReceivedEmailCount == 0 && waitLoopCount < 100) { waitLoopCount++; Thread.Sleep(300); } var email = smtpServer.ReceivedEmail.First(); Assert.AreEqual("some body", email.Body); Assert.AreEqual("some subject", email.Subject); Assert.AreEqual("bar", email.Headers.Get("foo")); }
public static void StopEmailServer(SimpleSmtpServer server) { if (server != null) { server.Stop(); } }
public void Setup() { var containerBuilder = new ContainerBuilder(); const int port = 587; const string hostName = "localhost"; var smtpHost = new SmtpHost(); smtpHost.HostName = hostName; smtpHost.Password = ""; smtpHost.Port = port; smtpHost.Ssl = true; smtpHost.Username = ""; var simpleSmtpServer = SimpleSmtpServer.Start(port); var outlookMailClientSettingMock = new Mock <IMailClientSetting>(); outlookMailClientSettingMock.Setup(options => options.Timeout).Returns(30); outlookMailClientSettingMock.Setup(options => options.DisplayName).Returns(OutlookDisplayName); outlookMailClientSettingMock.Setup(options => options.UniqueName).Returns(OutlookUniqueName); outlookMailClientSettingMock.Setup(options => options.MailHost).Returns(smtpHost); containerBuilder.RegisterInstance(outlookMailClientSettingMock.Object).AsImplementedInterfaces() .SingleInstance(); containerBuilder.RegisterType <OutlookMailClient>().AsImplementedInterfaces().InstancePerLifetimeScope(); containerBuilder.RegisterInstance(simpleSmtpServer) .SingleInstance(); AutofacContainer = containerBuilder.Build(); }
public BirthdayGreetingsFixture(string inputLine) { using (SimpleSmtpServer smtp = SimpleSmtpServer.Start(8025)) { using (FileStream file = File.Open("employees.txt", FileMode.Create)) using (StreamWriter writer = new StreamWriter(file)) { writer.WriteLine("last_name, first_name, date_of_birth, email"); writer.WriteLine(inputLine); } Process service = new Process(); service.StartInfo.Arguments = "127.0.0.1 8025 employees.txt"; #if DEBUG service.StartInfo.FileName = @"..\..\..\BirthdayGreetings\bin\Debug\BirthdayGreetings.exe"; #else service.StartInfo.FileName = @"..\..\..\BirthdayGreetings\bin\Release\BirthdayGreetings.exe"; #endif service.StartInfo.WorkingDirectory = Environment.CurrentDirectory; try { service.Start(); service.WaitForExit(); } finally { File.Delete("employees.txt"); } ExitCode = service.ExitCode; ReceivedEmails = smtp.ReceivedEmail.ToArray(); } }
public MailKitTests() { LogManager.GetLogger = type => new ConsoleLogger(type); _server = Configuration.Configure() .WithRandomPort() .Build(); }
public SmtpClientProviderTests() { _server = SimpleSmtpServer.Start(64666); _settings = new Mock <ISmtpClientProviderSettings>(); _settings.SetupGet(s => s.DisableDelivery).Returns(false); _settings.SetupGet(s => s.Host).Returns("localhost"); _settings.SetupGet(s => s.Port).Returns(_server.Port); }
protected override void TearDownEachTest() { Core.Context.TestContext.TearDown(); SimpleSmtpServer.EnsureAllEmailsPickedUp(); base.TearDownEachTest(); }
public void SetUp() { _server.ClearReceivedEmail(); _server.Stop(); _server.Dispose(); _server = SimpleSmtpServer.Start(_rnd.Next(50000, 60000)); _settings = GetSettings(); }
public SmptWrapper() { var port = rnd.Next(50000, 60000); this.settingsSwitcher = new SettingsSwitcher("MailServerPort", port.ToString()); this.SmtpServerInstance = SimpleSmtpServer.Start(Settings.MailServerPort); }
public AppTests() { smtpServer = SimpleSmtpServer.Start(smtpConfiguration.Port); app = new GreetingsAppBuilder() .WithEmployeeCatalog(x => x.FileSystem(fileConfiguration)) .WithGreetingsNotification(x => x.Smtp(smtpConfiguration)) .Build(); }
private LocalMailServer(int port) { _completion = new TaskCompletionSource <string>(); _timeoutCancelationToken = new CancellationTokenSource(); _server = SimpleSmtpServer.Start(port); _server.MessageReceived += OnMessageReceived; }
public void SetUp() { BaseSetup(); //TEST smtp server https://github.com/cmendible/netDumbster server = SimpleSmtpServer.Start(25); CreateSampleData(WinApp); CreateSampleData(AspApp); }
public static void StartSmtpServer(int port, int limit) { Inbox = new Inbox(limit, Inbox); SmtpServer = SimpleSmtpServer.Start(port); IsSmtpServerOn = true; MaximumLimit = limit; SmtpServer.MessageReceived += SmtpServer_MessageReceived; }
public override void Stop() { logger.Info("Stopping SMTP Server on port {0}", _port); base.Stop(); if (_smtpServer != null) { _smtpServer.Stop(); _smtpServer = null; } }
public void SetUpTest() { this.Driver = !TestConfig.UseExistingInstallation ? TestSetup._testBase.ChromeDriver : new ChromeDriver(); if (TestConfig.UseTestMailServer) { this.TestMailServer = SimpleSmtpServer.Start(TestConfig.TestMailPort.ToType <int>()); } Assert.IsTrue(this.LoginUser(), "Login failed"); }
protected override void BuildDataList() { scenarioContext.TryGetValue("variableList", out List <Tuple <string, string> > variableList); if (variableList == null) { variableList = new List <Tuple <string, string> >(); scenarioContext.Add("variableList", variableList); } variableList.Add(new Tuple <string, string>(ResultVariable, "")); BuildShapeAndTestData(); scenarioContext.TryGetValue("body", out string body); scenarioContext.TryGetValue("subject", out string subject); scenarioContext.TryGetValue("fromAccount", out string fromAccount); scenarioContext.TryGetValue("password", out string password); scenarioContext.TryGetValue("simulationOutput", out string simulationOutput); scenarioContext.TryGetValue("to", out string to); scenarioContext.TryGetValue("isHtml", out bool isHtml); var server = SimpleSmtpServer.Start(25); scenarioContext.Add("server", server); var selectedEmailSource = new EmailSource { Host = "localhost", Port = 25, UserName = "", Password = "", ResourceName = Guid.NewGuid().ToString(), ResourceID = Guid.NewGuid() }; ResourceCatalog.Instance.SaveResource(Guid.Empty, selectedEmailSource, ""); var sendEmail = new DsfSendEmailActivity { Result = ResultVariable, Body = string.IsNullOrEmpty(body) ? "" : body, Subject = string.IsNullOrEmpty(subject) ? "" : subject, FromAccount = string.IsNullOrEmpty(fromAccount) ? "" : fromAccount, To = string.IsNullOrEmpty(to) ? "" : to, SelectedEmailSource = selectedEmailSource, IsHtml = isHtml }; TestStartNode = new FlowStep { Action = sendEmail }; scenarioContext.Add("activity", sendEmail); }
public static void StartSmtpServer(int port, int limit) { if (ReceivedEmails.Count > limit) { ReceivedEmails.RemoveRange(limit - 1, ReceivedEmails.Count - limit); } SmtpServer = SimpleSmtpServer.Start(port); IsSmtpServerOn = true; MaximumLimit = limit; SmtpServer.MessageReceived += SmtpServer_MessageReceived; }
public void ShouldSendEmailWithContent(string email, string content, string subject) { using (var smtp = SimpleSmtpServer.Start()) { var sender = new EmailSender(); sender.Send($"{email}@example.com", content, subject); smtp.ReceivedEmail.First().Subject.Should().Be(subject); smtp.ReceivedEmail.First().Body.Should().Be(content); smtp.ReceivedEmail.First().To.First().Should().Be($"{email}@example.com"); } }
public void SetUp() { _server = Configuration.Configure() .WithRandomPort() .Build(); _emailConfiguration = new EmailConfiguration() { From = "*****@*****.**", Port = _server.Configuration.Port, SmtpServer = "localhost", DefaultSubject = "Message from arpa" }; _templateParser = Substitute.For <ITemplateParser>(); }
public void MultipleServerPort() { int ALT_PORT = 2525; // Start second server server2 = SimpleSmtpServer.Start(ALT_PORT); // Send to first server System.Web.Mail.SmtpMail.SmtpServer = "localhost"; System.Web.Mail.SmtpMail.Send("*****@*****.**", "*****@*****.**", "This is the subject", "This is the body."); // Send to second server MailMessage mail = new MailMessage(); mail.To = "*****@*****.**"; mail.From = "*****@*****.**"; mail.Subject = "This is the second subject"; mail.Body = "This is the second body."; mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", ALT_PORT.ToString()); SmtpMail.Send(mail); // Check first server Assert.AreEqual(1, server.ReceivedEmail.Length, "server.ReceivedEmail.Length"); Assert.AreEqual(1, server.ReceivedEmailCount, "server.ReceivedEmailSize"); SmtpMessage email = server.ReceivedEmail[0]; Assert.AreEqual("<*****@*****.**>", email.Headers["To"]); Assert.AreEqual("<*****@*****.**>", email.Headers["From"]); Assert.AreEqual("text/plain;", email.Headers["Content-Type"]); Assert.AreEqual("This is the subject", email.Headers["Subject"]); Assert.AreEqual("This is the body.", email.Body); // Check second server Assert.AreEqual(1, server2.ReceivedEmail.Length, "server.ReceivedEmail.Length"); Assert.AreEqual(1, server2.ReceivedEmailCount, "server.ReceivedEmailSize"); SmtpMessage email1 = server2.ReceivedEmail[0]; Assert.AreEqual("<*****@*****.**>", email1.Headers["To"]); Assert.AreEqual("<*****@*****.**>", email1.Headers["From"]); Assert.AreEqual("text/plain;", email1.Headers["Content-Type"]); Assert.AreEqual("This is the second subject", email1.Headers["Subject"]); Assert.AreEqual("This is the second body.", email1.Body); }
public async Task ServerUnreachableOnFirstSend() { using var smtpServer = SimpleSmtpServer.Start(smtpConfiguration.Port); using var notification = new SmtpGreetingsNotification(smtpConfiguration); smtpServer.Stop(); var ex = await Assert.ThrowsAsync <SmtpException>(() => notification.SendBirthday(new[] { new EmailInfo("foo", "*****@*****.**"), })); Assert.Equal(SmtpStatusCode.GeneralFailure, ex.StatusCode); }
public void Send_Fires_Message_Received_Event() { int port = 50004; SimpleSmtpServer fixedPortServer = this.StartServer(port); fixedPortServer.MessageReceived += (sender, args) => { Assert.NotNull(args.Message); Assert.Equal(1, fixedPortServer.ReceivedEmailCount); Assert.Equal("this is the body", args.Message.MessageParts[0].BodyData); }; this.SendMail(false, false, null, port); fixedPortServer.Stop(); }