4

Resolved

Session log is created but no corresponding Message is received

description

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

d1rtym0nk3y wrote May 10, 2011 at 9:47 AM

I'm seeing exactly the same behaviour whilst trying to send email from Adobe Coldfusion 9.0.1
What appears to be a partial session log is created but no message.

220 localhost smtp4dev ready
EHLO MC03
250-Nice to meet you.
250-8BITMIME
250 SIZE
MAIL FROM:server@localhost.dev
250 Okey dokey
RCPT TO:test@localhost.dev
250 Recipient accepted
RSET

wrote May 10, 2011 at 9:48 AM

d1rtym0nk3y wrote May 10, 2011 at 9:50 AM

Also, i should add, I'm running Win 7 64b ultimate

isxpjm wrote May 12, 2011 at 10:03 PM

Hi, I am getting the same problem. Here is the code snippet:

var smtpClient = new SmtpClient();
var mailMessage = new MailMessage
{
Subject = "Hello world",
Body = "Hello world",
From = new MailAddress("test@test.com") }; mailMessage.To.Add(new MailAddress("test@test.com")); Console.WriteLine("Sending e-mail...");
smtpClient.Send(mailMessage);
Console.WriteLine("E-mail sent.");

And app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.net>
    <mailSettings>
        <smtp>
            <network
      host="localhost"
      port="25"
    />
        </smtp>
    </mailSettings>
</system.net>
</configuration>

After about 30 seconds the session log appears, but no message:

220 localhost smtp4dev ready
EHLO phil-PC
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=9216
MAIL FROM:test@test.com
250 Okey dokey
RCPT TO:test@test.com
250 Recipient accepted
RSET

Rob, please can you help?

wrote Jun 28, 2011 at 9:42 AM

balajiramesh wrote Jun 28, 2011 at 10:11 AM

ENV: Windows 7 Enterprise 32 bit

Exactly the same issue. Just a session and no message:

220 localhost smtp4dev ready
EHLO L-045144-A.SYMC.SYMANTEC.COM
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:smtp4dev@test.com
250 Okey dokey
RCPT TO:balaji_ramesh@test.com
250 Recipient accepted
RSET
250 Rset completed
RSET
250 Rset completed

wrote Jul 21, 2011 at 7:04 AM

daina wrote Jul 21, 2011 at 8:13 AM

I have the same problem running a script from PHP 5.2 on IIS 7.5 - Win 7 64b professional, that worked fine on Win XP professional virtual SMTP server.
This is the crash report:

Description:
Stopped working

Problem signature:
Problem Event Name: CLR20r3
Problem Signature 01: smtp4dev.exe
Problem Signature 02: 2.0.5.0
Problem Signature 03: 4be9ca2f
Problem Signature 04: Rnwood.SmtpServer
Problem Signature 05: 2.0.5.0
Problem Signature 06: 4be9ca2b
Problem Signature 07: 16
Problem Signature 08: 0
Problem Signature 09: System.IndexOutOfRangeException
OS Version: 6.1.7600.2.0.0.256.48
Locale ID: 1027

wrote Jul 22, 2011 at 8:35 AM

rnwood wrote Jul 22, 2011 at 8:54 AM

I have reproduced this problem and believe this should now be fixed in the following release:
http://smtp4dev.codeplex.com/releases/view/70460

If possible please could you confirm that this fixes your problem.

rnwood wrote Jul 22, 2011 at 8:54 AM

I have reproduced this problem and believe this should now be fixed in the following release:
http://smtp4dev.codeplex.com/releases/view/70460

If possible please could you confirm that this fixes your problem.

rnwood wrote Jul 22, 2011 at 8:56 AM

I have reproduced this problem and believe this should now be fixed in the following release:
http://smtp4dev.codeplex.com/releases/view/70460

If possible please could you confirm that this fixes your problem.

rnwood wrote Jul 22, 2011 at 8:56 AM

I have reproduced this problem and believe this should now be fixed in the following release:
http://smtp4dev.codeplex.com/releases/view/70460

If possible please could you confirm that this fixes your problem.

balajiramesh wrote Jul 22, 2011 at 9:46 AM

I still experience the same behavior with 2.0.06:

220 localhost smtp4dev ready
EHLO NEXUS
250-Nice to meet you.
250 8BITMIME
MAIL FROM:tc@local.com
250 Okey dokey
RCPT TO:balaji@local.com
250 Recipient accepted
RSET

No message yet...

rnwood wrote Jul 24, 2011 at 4:50 PM

Can anybody elae please confirm what balajiramesh is saying - that this bug still occurs 2.0.6?
I am unable to reproduce now.

d1rtym0nk3y wrote Jul 24, 2011 at 7:59 PM

yes i'm still seeing this issue. I uninstalled then re-installed using the 2.0.6 installer. I still get a partial session log but no email is received. I'm running Win7 64bit if thats of any relevance

rnwood wrote Jul 25, 2011 at 7:50 PM

Thanks for the information. I'm still unable to reproduce against 2.0.6 on Win7 32bit. I suspect that the problem is only apparent on Windows 7 64 bit and I will try reproduce on this OS as soon as I get a chance. Unfortunately I don't have access to a 64 bit Win 7 machine most of the time so this could be a few days away.

In the mean time if anybody could send me a network capture (wireshark etc) of the traffic between a client and SMTP4dev experiencing this issue then that will speed up my investigation. Since wireshark can't capture on the loopback interface, you'd have to do this between 2 machines.

To explain what the session log posted is showing. The last response apparently sent by the server is a 250 (OK) response, what should happen next is for the client to send a DATA request, but this doesn't seem to be happening. The few seconds of pause are the smtp client timeout waiting for the server to respond. Somehow either the 250 response isn't making it to the client, or the client isn't considering it to be a complete response.

wrote Jul 25, 2011 at 7:50 PM

rnwood wrote Jul 25, 2011 at 8:28 PM

Please can somebody who can reproduce the problem try build 2.0.7 at the following URL:
http://smtp4dev.codeplex.com/releases/view/70665

rnwood wrote Aug 15, 2011 at 1:25 PM

I've now had the chance to test this on a Windows 7 64bit OS running in both a 32bit and 64bit process, and I'm unable to reproduce the problem.
Does anybody experiencing this problem have personal firewall/security software running and if possible can you try disable it temporarily and try again?

isxpjm wrote Aug 15, 2011 at 9:05 PM

Rob, Version 2.0.9 seems to have fixed the issue. Thanks for looking at this.

d1rtym0nk3y wrote Aug 15, 2011 at 9:51 PM

can also confirm 2.0.9 works for me
thanks for fixing this

wrote Aug 23, 2011 at 1:11 PM

spongeboy wrote Apr 10, 2012 at 9:00 AM

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.

spongeboy wrote Apr 10, 2012 at 9:46 AM

I added a few System.Threading.Thread.Sleep(1000), but still getting error messages. Oh well.

spongeboy wrote Apr 10, 2012 at 10:22 AM

This is not just an issue with smtp4dev - I've gotten the same error with DevNullSmtpServer.

My current guess is anti-virus. I have Symantec and Outlook 2010 on the machine.

spongeboy wrote Apr 10, 2012 at 10:28 AM

I was getting this same error with DevNullSmtp (a similar Java app). Whilst turning on and off a SMTP server, I got an error message from "Symantec Email Proxy", which pointed me to the solution-

Disable SYMANTEC INTERNET EMAIL AUTO-PROTECT
  1. Open Symantec Endpoint Protection Manager
  2. Click "Options" for "Virus and Spyware Protection"
  3. Go to "Internet Email Auto-Protect" tab
  4. Uncheck "Enable Internet Email Auto-Protect"

wrote Feb 22, 2013 at 1:30 AM

wrote May 16, 2013 at 12:42 PM

wrote May 16, 2013 at 12:42 PM

wrote Jun 14, 2013 at 8:31 AM

nicoandres57 wrote Jun 17, 2013 at 5:09 PM

Thanks, spongeboy, I have Symantec Endpoint Protection and uncheck "Enable Internet Email Auto-Proyect", works for me,

Thanks,

ayitey wrote Jan 27, 2014 at 9:28 PM

I had the same problem, but in my environment, I do not have permission to disable Symantic Internet Email Auto-Protect. (Lame!)

However, an easy workaround is to change the port configuration in SMTP4DEV, so it is not listening on the standard SMTP port 25. I changed it to a different port, and changed the port on the configuration of the application that needs to send email to use the same port.

Thus, Symantec doesn't recognize this as an SMTP communication, and everything works correctly.

zanlok wrote Jul 26, 2014 at 10:01 PM

This is still a problem for me with smtp4dev 2.0.9 on W7x64 ultimate. Tried changing to non-default port of 2500 with the same results: No actual messages, but a session item is in there as per example below...

220 localhost smtp4dev ready
EHLO COMPUTER-NAME
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=5000000
MAIL FROM:noreply.registration@ieminc.org
250 Okey dokey
RCPT TO:email@address.com
250 Recipient accepted
DATA
354 End message with period

zanlok wrote Jul 26, 2014 at 10:10 PM

Oops -- thought I'd sanitized that log better.
Can you remove the contents of the "MAIL FROM" line above? Thanks.