Videos
Check out our tutorial video series.
Create an SMTP client in CSharp and access MailSlurp inboxes for testing and receiving emails using the built-in `System.Net.Mail` package.
You can use CSharp's built in SMTP client package . Let us use XUnit and the MailSlurp client to create an email address and send emails to it.
First add the package to your CSharp project
Configure your MailSlurp API Key with the email client:
Then you can create inboxes during tests or in your application to connect to SMTP:
Using XUnit you can connect to SMTP mailboxes during tests and send and receive emails.
You can use to send emails in DotNET but what if you want to receive emails instead? Use MailSlurps email webhooks to have emails sent directly to your server.
You can use the waitFor methods with the MailSlurp SDK client. You can receive emails using waitFor methods on the WaitForControllerApi class.
A common use case for temporary SMTP mailboxes in Csharp is verifying OTP 2FA login during integration testing. OTP one-time passwords are ephemeral codes that can be sent to a user's email address when they want to access a web application or mobile app.
See the OTP testing guide for more information.
Check out our tutorial video series.
Email and SMS guides for automation and testing.
View github project code for multiple languages.
Latest posts from the MailSlurp team.
Test, build, and automate messaging with a free MailSlurp account.