I have created the following simple ASP.NET 4.0 application to test sending an e-mail:
MailTestPage.aspx
----------------------
<%@ Page Language="C#" Debug="true" AutoEventWireup="true" CodeFile="MailTestPage.aspx.cs" Inherits="MailTestPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table border="0">
<tr>
<td><b>Your Email:</b></td>
<td><asp:TextBox runat="server" ID="UsersEmail" Columns="30"></asp:TextBox></td>
</tr>
<tr>
<td><b>Subject:</b></td>
<td><asp:TextBox runat="server" ID="Subject" Columns="30"></asp:TextBox></td>
</tr>
<tr>
<td colspan="2">
<b>Body:</b><br />
<asp:TextBox runat="server" ID="Body" TextMode="MultiLine" Columns="55" Rows="10"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:Button runat="server" ID="SendEmail" Text="Send E-mail"
onclick="SendEmail_Click" />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
MailTestPage.aspx.cs
-------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
public partial class MailTestPage : System.Web.UI.Page
{
protected void SendEmail_Click(object sender, System.EventArgs e)
{
const string ToAddress = "emerald77@att.net";
MailMessage mm = new MailMessage(UsersEmail.Text, ToAddress);
mm.Subject = Subject.Text;
mm.Body = Body.Text;
mm.IsBodyHtml = false;
SmtpClient smtp = new SmtpClient();
//(use the Web.config settings)
smtp.Send(mm);
}
}
web.config
-------------
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network host="localhost" port="25"/>
</smtp>
</mailSettings>
</system.net>
</configuration>
After I create the e-mail message and click the "Send E-mail" button, it takes about 15 seconds before smtp4dev displays the following Session log:
220 localhost smtp4dev ready
EHLO mickey
250-Nice to meet you.
250-8BITMIME
250-STARTTLS
250-AUTH=CRAM-MD5 PLAIN LOGIN ANONYMOUS
250-AUTH CRAM-MD5 PLAIN LOGIN ANONYMOUS
250 SIZE
MAIL FROM:<test@domain.com>
250 Okey dokey
RCPT TO:<emerald77@att.net>
250 Recipient accepted
RSET
However, the e-mail message does not show up under the "Messages" tab of smtp4dev. I'm not sure if the problem is due to pilot error or there is a bug in smtp4dev.
Thanks in advance for any assistance with this issue.
Bob
Comments: ** Comment from web user: spongeboy **
MailTestPage.aspx
----------------------
<%@ Page Language="C#" Debug="true" AutoEventWireup="true" CodeFile="MailTestPage.aspx.cs" Inherits="MailTestPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table border="0">
<tr>
<td><b>Your Email:</b></td>
<td><asp:TextBox runat="server" ID="UsersEmail" Columns="30"></asp:TextBox></td>
</tr>
<tr>
<td><b>Subject:</b></td>
<td><asp:TextBox runat="server" ID="Subject" Columns="30"></asp:TextBox></td>
</tr>
<tr>
<td colspan="2">
<b>Body:</b><br />
<asp:TextBox runat="server" ID="Body" TextMode="MultiLine" Columns="55" Rows="10"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:Button runat="server" ID="SendEmail" Text="Send E-mail"
onclick="SendEmail_Click" />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
MailTestPage.aspx.cs
-------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
public partial class MailTestPage : System.Web.UI.Page
{
protected void SendEmail_Click(object sender, System.EventArgs e)
{
const string ToAddress = "emerald77@att.net";
MailMessage mm = new MailMessage(UsersEmail.Text, ToAddress);
mm.Subject = Subject.Text;
mm.Body = Body.Text;
mm.IsBodyHtml = false;
SmtpClient smtp = new SmtpClient();
//(use the Web.config settings)
smtp.Send(mm);
}
}
web.config
-------------
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network host="localhost" port="25"/>
</smtp>
</mailSettings>
</system.net>
</configuration>
After I create the e-mail message and click the "Send E-mail" button, it takes about 15 seconds before smtp4dev displays the following Session log:
220 localhost smtp4dev ready
EHLO mickey
250-Nice to meet you.
250-8BITMIME
250-STARTTLS
250-AUTH=CRAM-MD5 PLAIN LOGIN ANONYMOUS
250-AUTH CRAM-MD5 PLAIN LOGIN ANONYMOUS
250 SIZE
MAIL FROM:<test@domain.com>
250 Okey dokey
RCPT TO:<emerald77@att.net>
250 Recipient accepted
RSET
However, the e-mail message does not show up under the "Messages" tab of smtp4dev. I'm not sure if the problem is due to pilot error or there is a bug in smtp4dev.
Thanks in advance for any assistance with this issue.
Bob
Comments: ** Comment from web user: spongeboy **
Still happening to me on Windows 7, version 2.0.9 and 2.1.1.0Alpha.
I tried catching the packets with Fiddler - but from a different computer it worked! Only occurring when sending from the same machine as the server.
I've tried-
* Running server as administrator
My gut feeling is that the server is replying too quickly. Maybe adding a delay before replying might fix this.