Skip to content

Instantly share code, notes, and snippets.

@johndobrien
Created August 19, 2017 20:01
Show Gist options
  • Save johndobrien/bb2683b6c61907d2bf6422c842107b2b to your computer and use it in GitHub Desktop.
Save johndobrien/bb2683b6c61907d2bf6422c842107b2b to your computer and use it in GitHub Desktop.
Testing SMTP
DotNetOpenMailProvider provider = new DotNetOpenMailProvider();
NameValueCollection configValue = new NameValueCollection();
configValue["smtpServer"] = "127.0.0.1";
configValue["port"] = "8081";
provider.Initialize("providerTest", configValue);
TestSmtpServer receivingServer = new TestSmtpServer();
try
{
receivingServer.Start("127.0.0.1", 8081);
provider.Send("phil@example.com",
"nobody@example.com",
"Subject to nothing",
"Mr. Watson. Come here. I need you.");
}
finally
{
receivingServer.Stop();
}
// So Did It Work?
Assert.AreEqual(1, receivingServer.Inbox.Count);
ReceivedEmailMessage received = receivingServer.Inbox[0];
Assert.AreEqual("phil@example.com", received.ToAddress.Email);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment