Many time developer need to do quick test about SMTP is working or not. I think most of the time developer add some code in project and deploy for testing.
So for testing instead of compile and deploy; we can test quickly in less efforts.
Create .aspx file using any simple editor and put file within sitecore website folder where you can access from browser. I normally put in layout folder and delete after testing.
Code is
<%@ Page Language="C#" %> <%@ Import Namespace="System.Net.Mail" %> <%@ Import Namespace="Sitecore" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>SMTP Testing</title> </head> <body> <form id="form1" runat="server"> <asp:TextBox runat="server" ID="txtEmailTo" Text="[email protected]"/> <br/> <asp:Button runat="server" Text="Send test email" ID="btnSendEmail" OnClick="btnSendEmail_OnClick"/> </form> </body> </html> <script language="c#" runat="server"> protected void btnSendEmail_OnClick(object sender, EventArgs e) { var emailMessage = new MailMessage("[email protected]", txtEmailTo.Text, "SMTP Test", "Testing email from TestSMTP.aspx"); MainUtil.SendMail(emailMessage); Response.Write("Email sent!!"); } </script>