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 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 ServerCanRunOnDifferentPort() { // Server is already running. We check that this cause an SocketException to be thrown var alternateServer = SimpleSmtpServer.Start(ALT_PORT); alternateServer.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 void Setup() { // NB Use port configured in App.config var client = new SmtpClient(); smtpServer = 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 void SetUp() { _simpleSmtpServer = SimpleSmtpServer.Start(25); Environment.SetEnvironmentVariable("Host", "localhost"); Environment.SetEnvironmentVariable("Port", "25"); new SmtpMailer(); }
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 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 AppTests() { smtpServer = SimpleSmtpServer.Start(smtpConfiguration.Port); app = new GreetingsAppBuilder() .WithEmployeeCatalog(x => x.FileSystem(fileConfiguration)) .WithGreetingsNotification(x => x.Smtp(smtpConfiguration)) .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); }
private LocalMailServer(int port) { _completion = new TaskCompletionSource <string>(); _timeoutCancelationToken = new CancellationTokenSource(); _server = SimpleSmtpServer.Start(port); _server.MessageReceived += OnMessageReceived; }
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 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 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 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 Setup() { _smtpServer = SimpleSmtpServer.Start(); _currentEmailConfig = new EmailConfiguration( smtpServerName: "localhost", portNumber: 25, subject: "errormail", recipients: "", senderAddress: "*****@*****.**"); _currentEmailConfig.Recipients.Add("*****@*****.**"); _currentEmailConfig.Recipients.Add("*****@*****.**"); _eventReader = new EventReader(new EventLog("Security"), TimeSpan.FromHours(12)); }
public static void AddServer(string name, int port) { if (Servers.ContainsKey(port)) { throw new Exception(string.Format("Smtp already exists with name {0}", port)); } var server = SimpleSmtpServer.Start(port); Servers[port] = new Server { Created = DateTime.UtcNow, Name = name, Port = port, SmtpServer = server }; }
public async Task SendBirthday() { using var smtpServer = SimpleSmtpServer.Start(smtpConfiguration.Port); using var notification = new SmtpGreetingsNotification(smtpConfiguration); await notification.SendBirthday(new[] { new EmailInfo("foo", "*****@*****.**"), }); ReceivedMail.FromAll(smtpServer) .Should() .BeEquivalentTo(new ReceivedMail(smtpConfiguration.Sender, "*****@*****.**", "Happy birthday!", "Happy birthday, dear foo!")); }
private static Task MailServer() { int port = 25; //SMTP endpoint mail_server = SimpleSmtpServer.Start(port); mail_server.MessageReceived += (sender, mail) => { // Get message body. var head = mail.Message.FromAddress; var body = mail.Message.MessageParts[0].BodyData; Console.WriteLine("Got Mail: " + head + "\n" + body); }; Console.WriteLine("SMTP server open on " + port); return(Task.CompletedTask); }
static void Main(string[] args) { SimpleSmtpServer server = SimpleSmtpServer.Start(); while (true) { if (server.ReceivedEmailCount > 0) { foreach (SmtpMessage message in server.ReceivedEmail) { Console.WriteLine("----------------------------------------------------------------"); Console.WriteLine(); Console.WriteLine(message.ToString()); } server.ClearReceivedEmail(); } Thread.Sleep(100); } }
public static void InitTests(TestContext context) { const int DEFAULT_PORT = 2773; Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); MailSettingsSectionGroup mailSettings = config.GetSectionGroup("system.net/mailSettings") as MailSettingsSectionGroup; int port; if (mailSettings != null) { port = mailSettings.Smtp.Network.Port; } else { port = DEFAULT_PORT; } _server = SimpleSmtpServer.Start(port); }
protected override void RegisterDependencies(Container container) { base.RegisterDependencies(container); var localizer = Substitute.For <IViewLocalizer>(); localizer.GetString(Arg.Any <string>()).ReturnsForAnyArgs(_ => new LocalizedString("Subject", "The subject")); container.RegisterInstance(localizer); SmtpServer = SimpleSmtpServer.Start(); container.RegisterEmail(c => { c.CssPath = "email.css"; c.SmtpServer = "localhost"; c.SmtpPort = SmtpServer.Configuration.Port; c.SenderAddress = "*****@*****.**"; c.SenderName = "Test Fusonic"; }); }