Mail sent through IIS virtual SMTP server not arriving

A

antonyliu2002

I've set up the virtual smtp server on my IIS 5.1 like so:

1. Assign IP address to "All Unassigned", and listen to port 25.
2. Access Connection granted to "127.0.0.1".
3. Relay only allow "127.0.0.1".
4. Authentication: "Anonymous access" only.
5. Outbound connection listen to TCP 25.

Besides,

6. I've opened up port 25 in my Linksys WRT45G wireless router.
7. I've made port 25 an exception in my WinXP Pro built-in firewall.
8. Unblocked port 25 in McAfee 8.0 enterprise edition.

I used the following code, and

Response.Write("Your E-mail has been sent sucessfully - Thank You")

is executed and I don't see any exception.

However, the mail never arrived!

So, what's the problem?

Is it possible to configure the virtual SMTP server to listen to a
non-standard port for just sending email? I heard that my ISP SBC DSL
blocks port 25. If this is possible, how to let it listen to a
different port?

***** The code I use ***********

<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Web.Mail" %>

<script runat="server">

Sub btnSubmit_Click(sender as object, e as EventArgs)
If Page.IsValid Then
' Create a new blank MailMessage
Dim mailMessage As MailMessage = new MailMessage ()
mailMessage.From = txtFrom.Text
mailMessage.To = txtTo.Text
mailMessage.Cc = txtCc.Text
mailMessage.Subject = "Test SMTP Message Send using port"
mailMessage.Body = txtName.Text & ", " &txtComments.Text
SmtpMail.SmtpServer = "127.0.0.1"

Try
SmtpMail.Send(mailMessage)
Response.Write("Your E-mail has been sent sucessfully - Thank You")
Catch ex As Exception
Response.Write(("The following exception occurred: " +
ex.ToString()))
'check the InnerException
While Not (ex.InnerException Is Nothing)
Response.Write("--------------------------------")
Response.Write(("The following InnerException reported: "
+ ex.InnerException.ToString()))
ex = ex.InnerException
End While
End Try
End If
End Sub
</script>

The HTML that follows this code snippet is not pasted.
 
B

Bruce Barker

you probably need to configure the smtp server to correctly forward mail to
your isp's smtp server. does the isp smtp require authenication? does it
require the from match authenication?

-- bruce (sqlwork.com)
 
S

sloan

2/8/2006

http://spaces.msn.com/sholliday/


Check this blog.

This will help you with the coding side of the issue. I have 1.1 and
2.0 code.

as far as the IIS setup
Then check the wwwroot\mail\queue folder.

If items are "stuck" in here, then the issue is your smarthost setup
(the stuff you describe below).


Sometimes its a tug and pull affair, and it depends on the end isp you
have.

my smtp.nc.rr.com was finicky.
 
A

antonyliu2002

Thanks, Bruce.

I know that I won't have any problem for my application in sending and
receiving email if I simply use the SMTP server of my ISP. I tried it,
and it worked perfectly fine. And in this case, I don't have do
anything about the virtual SMTP server on my IIS 5.1.

But, I am trying to test if I can send email in my web application
through the IIS virtual SMTP server only.

So if I end up having to forward to my ISP's SMTP server, it'll beat my
objective, plus, I could have just used my ISP's SMTP service.

So, any idea about why I am not receiving the mail "sent" from the
virtual SMTP? By quoting "sent", I meant that at least it looks like
to have been sent.
 
A

antonyliu2002

Hi, Sloan,

Thanks. I just checked \Inetpub\mailroot\Queue\. Indeed, all of the
messages are lying there. So apparently, they were not sent.

Don't know what went wrong. So, you think it has to do with my ISP:
SBC DSL?

I know that they block port 25. So, is it possible to set up my IIS
SMTP server to listen to a nonstandard port for just outgoing messages?
 
J

Juan T. Llibre

re:
By quoting "sent", I meant that at least it looks like to have been sent.

The way to find out, for sure, is to turn on smtp logging.

To turn on logging, open the IIS Manager,
and select the Default SMTP Server's properties.

You'll see the option for turning it on and for selecting the type of log.
Clicking the Properties and then the Advanced button lets you select the fields to log.

The log, by default, will be stored at \windowsdir\system32\LogFiles\smtpsvc1

You should see entries like :
2006-03-01 14:58:32 111.111.111.111 smtpservername SMTPSVC1 0 HELO 250 33 - -
2006-03-01 14:58:32 111.111.111.111 smtpservername SMTPSVC1 0 MAIL 250 47 - -
2006-03-01 14:58:32 111.111.111.111 smtpservername SMTPSVC1 0 RCPT 250 34 - -
2006-03-01 14:58:32 111.111.111.111 smtpservername SMTPSVC1 0 DATA 250 125 - -

If the mail packet was successfully sent, the success code is 250.

Any other code means some sort of problem
which prevented the mail from getting sent.

Check that...and let us know what you see after you attempt to send mail.
 
A

antonyliu2002

Hi, Juan,

Thanks, I just checked the logfile like you instructed. And here is a
part of it. You will see GET /favicon.ico 404 in the log. And here is
a dicussion of it:

http://www.webmasterworld.com/forum39/104.htm

And for the definition of the HTTP code 200, see here:

http://64.233.179.104/search?q=cach...0.html+http+code+200&hl=en&gl=us&ct=clnk&cd=1

So, given the log below, could you diagnose what problem it is?

Thanks.

#Software: Microsoft Internet Information Services 5.1
#Version: 1.0
#Date: 2006-03-02 18:25:16
#Fields: time c-ip cs-method cs-uri-stem sc-status
18:25:16 130.126.83.20 POST /sendmail/vmailman.aspx 200
18:25:16 130.126.83.20 GET /favicon.ico 404
18:28:41 130.126.83.20 POST /sendmail/vmailman.aspx 200
18:28:41 130.126.83.20 GET /favicon.ico 404
18:29:24 130.126.83.20 GET /sendmail/vmailman.aspx 200
18:29:24 130.126.83.20 GET /favicon.ico 404
18:29:43 130.126.83.20 POST /sendmail/vmailman.aspx 200
18:29:43 130.126.83.20 GET /favicon.ico 404
18:31:35 130.126.83.20 POST /sendmail/vmailman.aspx 200
18:31:35 130.126.83.20 GET /favicon.ico 404
18:31:39 130.126.83.20 POST /sendmail/vmailman.aspx 200
18:31:39 130.126.83.20 GET /favicon.ico 404
18:31:41 130.126.83.20 POST /sendmail/vmailman.aspx 200
18:31:41 130.126.83.20 GET /favicon.ico 404
18:31:42 130.126.83.20 POST /sendmail/vmailman.aspx 200
18:31:42 130.126.83.20 GET /favicon.ico 404
18:34:02 130.126.83.20 GET /sendmail/vmailman.aspx 200
18:34:02 130.126.83.20 GET /favicon.ico 404
18:34:18 130.126.83.20 POST /sendmail/vmailman.aspx 200
18:34:18 130.126.83.20 GET /favicon.ico 404
18:44:53 130.126.83.20 GET /sendmail/vmailman.aspx 200
18:44:53 130.126.83.20 GET /favicon.ico 404
18:45:42 130.126.83.20 POST /sendmail/vmailman.aspx 200
18:45:42 130.126.83.20 GET /favicon.ico 404
18:48:01 130.126.83.20 POST /sendmail/vmailman.aspx 200
18:48:01 130.126.83.20 GET /favicon.ico 404
18:50:32 130.126.83.20 POST /sendmail/vmailman.aspx 200
18:50:32 130.126.83.20 GET /favicon.ico 404
18:51:09 130.126.83.20 POST /sendmail/vmailman.aspx 200
18:51:09 130.126.83.20 GET /favicon.ico 404
18:51:10 130.126.83.20 POST /sendmail/vmailman.aspx 200
18:51:10 130.126.83.20 GET /favicon.ico 404
19:06:51 130.126.83.20 POST /sendmail/vmailman.aspx 200
19:06:51 130.126.83.20 GET /favicon.ico 404
22:30:59 194.72.238.61 HEAD /iisstart.asp 200
 
J

Juan T. Llibre

re:
I just checked the logfile like you instructed.

You checked the HTTP log ( \%windir%\system32\LogFiles\W3SVC1 ),
but not the SMTP log.

The line :
18:25:16 130.126.83.20 POST /sendmail/vmailman.aspx 200

tells you that you POSTed to sendmail.
It doesn't tell you what the smtp server did with that POST.

Please check the \%windir%\system32\LogFiles\smtpsvc1 logs.
( and send the last 8 lines of today's log... )





Hi, Juan,

Thanks, I just checked the logfile like you instructed. And here is a
part of it. You will see GET /favicon.ico 404 in the log. And here is
a dicussion of it:

http://www.webmasterworld.com/forum39/104.htm

And for the definition of the HTTP code 200, see here:

http://64.233.179.104/search?q=cach...0.html+http+code+200&hl=en&gl=us&ct=clnk&cd=1

So, given the log below, could you diagnose what problem it is?

Thanks.

#Software: Microsoft Internet Information Services 5.1
#Version: 1.0
#Date: 2006-03-02 18:25:16
#Fields: time c-ip cs-method cs-uri-stem sc-status
18:25:16 130.126.83.20 POST /sendmail/vmailman.aspx 200
18:25:16 130.126.83.20 GET /favicon.ico 404
 
A

antonyliu2002

Yes, I did notice that I was showing you something different from what
you wanted.

But I do not have anything under LogFiles except W3SVC1.

I probably did not check the log option for my virtual SMTP server.
Will have to do it tomorrow. I don't have access to my server right
now.

Thanks for your kindness.
 
A

antonyliu2002

Hi, Juan,

Now I am having the typical "Could not access 'CDO.Message' object" and
"The transport failed to connect to the server" exceptions.

I think this has something to do with the blocking of port 25 by my
ISP, SBC Yahoo DSL.

Too bad that the .Net SmtpMail class does not let us set the port
number. If it did, then I could probably just let the smtp server
listen to a nonstandard port just for outgoing mail.
 
A

antonyliu2002

Hi, Juan,

I got the smtp server log as follows. The code is 250, which according
to what you said meant that the mail has been sent successfully. But
the mail never arrived.

#Software: Microsoft Internet Information Services 5.1
#Version: 1.0
#Date: 2006-03-03 05:44:39
#Fields: time c-ip cs-method cs-uri-stem sc-status
05:44:39 127.0.0.1 HELO - 250
05:44:39 127.0.0.1 MAIL - 250
05:44:39 127.0.0.1 RCPT - 250
05:44:39 127.0.0.1 DATA - 250
05:44:39 127.0.0.1 QUIT - 0
05:50:26 127.0.0.1 HELO - 250
05:50:26 127.0.0.1 MAIL - 250
05:50:26 127.0.0.1 RCPT - 250
05:50:26 127.0.0.1 DATA - 250
05:50:26 127.0.0.1 QUIT - 0

Under Inetpub/mailroot/Queue, the email messages are all sleeping
there.

This is one of them:

Received: from jzgwxp ([127.0.0.1]) by jzgwxp with Microsoft
SMTPSVC(6.0.2600.2180);
Thu, 2 Mar 2006 12:34:18 -0600
thread-index: AcY+J+pQSe3Rk0ZnTkyyqJ2qLvMyog==
Thread-Topic: Test SMTP Message Send using port
From: <[email protected]>
To: <[email protected]>
Cc:
Subject: Test SMTP Message Send using port
Date: Thu, 2 Mar 2006 12:34:18 -0600
Message-ID: <002601c63e27$ea508530$1f12fea9@jzgwxp>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Mailer: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
Return-Path: (e-mail address removed)
X-OriginalArrivalTime: 02 Mar 2006 18:34:18.0273 (UTC)
FILETIME=[EA551910:01C63E27]

Wassup, man?
 
J

Juan T. Llibre

re:
Too bad that the .Net SmtpMail class does not let us set the port number.

But it does allow you to do that :

static void ChangePort()
{
//create the mail message
MailMessage mail = new MailMessage();

//set the addresses
mail.From = new MailAddress("(e-mail address removed)");
mail.To.Add("(e-mail address removed)");

//set the content
mail.Subject = "This is an email";
mail.Body = "this is the body content of the email.";

//send the message
SmtpClient smtp = new SmtpClient("127.0.0.1");

//to change the port (default is 25), we set the port property
smtp.Port = 587;
smtp.Send(mail);
}

Of course, for that to work you must set IIS's SMTP server
to the same port you set in your code. You can use any TCP port.

To do that, view the Properties of the Default SMTP Server;
click the "Delivery" tab; click the "Outbound Connections" button;
and set the port number you want in the "Tcp port" box.

That will get around your ISP's blockage of port 25.




Hi, Juan,

Now I am having the typical "Could not access 'CDO.Message' object" and
"The transport failed to connect to the server" exceptions.

I think this has something to do with the blocking of port 25 by my
ISP, SBC Yahoo DSL.

Too bad that the .Net SmtpMail class does not let us set the port
number. If it did, then I could probably just let the smtp server
listen to a nonstandard port just for outgoing mail.
 
J

Juan T. Llibre

It does look like your ISP is blocking port 25.
Read my previous post and test using a different port.




Hi, Juan,

I got the smtp server log as follows. The code is 250, which according
to what you said meant that the mail has been sent successfully. But
the mail never arrived.

#Software: Microsoft Internet Information Services 5.1
#Version: 1.0
#Date: 2006-03-03 05:44:39
#Fields: time c-ip cs-method cs-uri-stem sc-status
05:44:39 127.0.0.1 HELO - 250
05:44:39 127.0.0.1 MAIL - 250
05:44:39 127.0.0.1 RCPT - 250
05:44:39 127.0.0.1 DATA - 250
05:44:39 127.0.0.1 QUIT - 0
05:50:26 127.0.0.1 HELO - 250
05:50:26 127.0.0.1 MAIL - 250
05:50:26 127.0.0.1 RCPT - 250
05:50:26 127.0.0.1 DATA - 250
05:50:26 127.0.0.1 QUIT - 0

Under Inetpub/mailroot/Queue, the email messages are all sleeping
there.

This is one of them:

Received: from jzgwxp ([127.0.0.1]) by jzgwxp with Microsoft
SMTPSVC(6.0.2600.2180);
Thu, 2 Mar 2006 12:34:18 -0600
thread-index: AcY+J+pQSe3Rk0ZnTkyyqJ2qLvMyog==
Thread-Topic: Test SMTP Message Send using port
From: <[email protected]>
To: <[email protected]>
Cc:
Subject: Test SMTP Message Send using port
Date: Thu, 2 Mar 2006 12:34:18 -0600
Message-ID: <002601c63e27$ea508530$1f12fea9@jzgwxp>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Mailer: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
Return-Path: (e-mail address removed)
X-OriginalArrivalTime: 02 Mar 2006 18:34:18.0273 (UTC)
FILETIME=[EA551910:01C63E27]

Wassup, man?
 
A

antonyliu2002

Hi, Juan,

Thanks a lot. Unfortunately, it looks like that the SmtpClient is only
available with .Net framework 2.0

Quote from
http://msdn2.microsoft.com/en-us/library/system.net.mail.smtpclient.aspx

<quote>
SmtpClient Class
Note: This class is new in the .NET Framework version 2.0.
Allows applications to send e-mail by using the Simple Mail Transfer
Protocol (SMTP).

Namespace: System.Net.Mail
Assembly: System (in system.dll)
</quote>

I am using .Net Framework 1.1

I know nothing about 2.0 at this point of time. Is there any way to go
around this?

Thanks.
 
J

Juan T. Llibre

re:
I am using .Net Framework 1.1

Youi'll find sample code for changing the port number under system.web.amil here :

http://systemwebmail.com/faq/2.9.aspx

Essentially :


MailMessage mail = new MailMessage();
mail.To = "(e-mail address removed)";
mail.From = "(e-mail address removed)";
mail.Subject = "this is a test email.";
mail.Body = "Some text goes here";
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "your port number");
SmtpMail.SmtpServer = "YourSmtpServer";
SmtpMail.Send(mail);

There's VB.NET sample code in the same page.

Keep that systemwebmail link handy.
All the info you need to solve web mail problems under .Net 1.1 is there.

There's specific answers for both the "Could not access 'CDO.Message' object"
and "The transport failed to connect to the server" exceptions which you reported.






Hi, Juan,

Thanks a lot. Unfortunately, it looks like that the SmtpClient is only
available with .Net framework 2.0

I am using .Net Framework 1.1

I know nothing about 2.0 at this point of time. Is there any way to go
around this?
 
A

antonyliu2002

Hey, Juan,

I thought that it would work this time. But the mails are still not
sent!

I am using port number 5181. I have done the following:

1. opened up this port with my Linksys WRT54G wireless router.
2. make port 5181 an exception in my WinXP Pro built-in firewall.
3. opened up this port in McAfee 8.0 Enterprise edition.
4. in Outbound connections of the SMTP properties, I set the SMTP to
listen to port 5181.
5. in the General tab, for "All unassigned", I click "Advanced" and
assigned port 5181.

Still, the messages are queued up under Inetput/mailroot/Queue/. There
is no exception.

It did not work even after I did this, i.e., on the Security tab of the
SMTP properties, I added my username as well ASPNET to "Grant operator
permissions to these windows user accounts." Of course,
'administrator' is there by default.

Hmm, kinda frustrated.

Look, this is my current code (Again, the HTML is not pasted):

Sub btnSubmit_Click(sender as object, e as EventArgs)
If Page.IsValid Then
' Create a new blank MailMessage
Dim mailMessage As MailMessage = new MailMessage ()
mailMessage.From = txtFrom.Text
mailMessage.To = txtTo.Text
mailMessage.Cc = txtCc.Text
mailMessage.Subject = "Test SMTP Message Send using port"
mailMessage.Body = txtName.Text & ", " &txtComments.Text

mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport",
"5181")
SmtpMail.SmtpServer = "127.0.0.1"
'SmtpMail.Send(mail)

Try
SmtpMail.Send(mailMessage)
Response.Write("Your E-mail has been sent sucessfully - Thank You")
Catch ex As Exception
Response.Write(("The following exception occurred: " +
ex.ToString()))
'check the InnerException
While Not (ex.InnerException Is Nothing)
Response.Write("--------------------------------<br/>")
Response.Write(("The following InnerException reported: "
+ ex.InnerException.ToString()) + "<br/>")
ex = ex.InnerException
End While
End Try
End If
End Sub
 
A

antonyliu2002

It looks like that a lot of people have this problem, i.e., no
exception is thrown, but messages got packed up under
Inetpub/mailroot/Queue/ and never get sent. However, there does not
seem to have a solution so far. I googled around, only see people
asking for help, no one has really offered a solution to this problem.

At the following link, Leszek did say the problem was solved. But
she/he did not go into detail about her solution. E.g., How to set up
a real sender address on the SMTP virtual server? She/He did not
explain it.

Also, it looks like that she/he was using smarthost, which to my
understanding, is sending mail through a remote SMTP server provided by
some ISP. That would be a different story from what I am trying to
solve.

Here is that post:

http://groups.google.com/group/micr...server+configuration+&rnum=1#9675868e46c5729c

From: Leszek - view profile
Date: Tues, Sep 9 2003 7:39 am
Email: "Leszek" <[email protected]>
Groups: microsoft.public.inetserver.iis

Thank you very much.
There were several problems with my IIS configuration (smart host, smtp
server name etc). Moreover it turned out that I needed to set up a real
sender address (From: field) to enforce the IIS to send emails. Strange
but now it works perfectly.
 
J

Juan T. Llibre

Open the IIS Manager and check the properties for the smtp server.

In the Default SMTP Virtual Server's properties, in the "Access" tab, both
in the Connection Control and Relay dialogs, make sure that your local IP is assigned.
( In my case, it's 10.0.0.2... )

You may also need to modify your hosts file, to point 127.0.0.1 to your machine name.
( \WINDOWS\system32\drivers\etc\hosts )

Then, in your code, assign your machine name to the smtp client :

SmtpMail.SmtpServer = "YourMachineName";
SmtpMail.Send(mail);

This fixed the problem for me. I hope it does the same for you.




Hey, Juan,

I thought that it would work this time. But the mails are still not
sent!

I am using port number 5181. I have done the following:

1. opened up this port with my Linksys WRT54G wireless router.
2. make port 5181 an exception in my WinXP Pro built-in firewall.
3. opened up this port in McAfee 8.0 Enterprise edition.
4. in Outbound connections of the SMTP properties, I set the SMTP to
listen to port 5181.
5. in the General tab, for "All unassigned", I click "Advanced" and
assigned port 5181.

Still, the messages are queued up under Inetput/mailroot/Queue/. There
is no exception.

It did not work even after I did this, i.e., on the Security tab of the
SMTP properties, I added my username as well ASPNET to "Grant operator
permissions to these windows user accounts." Of course,
'administrator' is there by default.

Hmm, kinda frustrated.

Look, this is my current code (Again, the HTML is not pasted):

Sub btnSubmit_Click(sender as object, e as EventArgs)
If Page.IsValid Then
' Create a new blank MailMessage
Dim mailMessage As MailMessage = new MailMessage ()
mailMessage.From = txtFrom.Text
mailMessage.To = txtTo.Text
mailMessage.Cc = txtCc.Text
mailMessage.Subject = "Test SMTP Message Send using port"
mailMessage.Body = txtName.Text & ", " &txtComments.Text

mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport",
"5181")
SmtpMail.SmtpServer = "127.0.0.1"
'SmtpMail.Send(mail)

Try
SmtpMail.Send(mailMessage)
Response.Write("Your E-mail has been sent sucessfully - Thank You")
Catch ex As Exception
Response.Write(("The following exception occurred: " +
ex.ToString()))
'check the InnerException
While Not (ex.InnerException Is Nothing)
Response.Write("--------------------------------<br/>")
Response.Write(("The following InnerException reported: "
+ ex.InnerException.ToString()) + "<br/>")
ex = ex.InnerException
End While
End Try
End If
End Sub
 
J

Juan T. Llibre

Open the IIS Manager and check the properties for the smtp server.

In the Default SMTP Virtual Server's properties, in the "Access" tab, both
in the Connection Control and Relay dialogs, make sure that your local IP is assigned.
( In my case, it's 10.0.0.2... )

You may also need to modify your hosts file, to point 127.0.0.1 to your machine name.
( \WINDOWS\system32\drivers\etc\hosts )

Then, in your code, assign your machine name to the smtp client :

SmtpMail.SmtpServer = "YourMachineName";
SmtpMail.Send(mail);

This fixed the problem for me. I hope it does the same for you.





It looks like that a lot of people have this problem, i.e., no
exception is thrown, but messages got packed up under
Inetpub/mailroot/Queue/ and never get sent. However, there does not
seem to have a solution so far. I googled around, only see people
asking for help, no one has really offered a solution to this problem.

At the following link, Leszek did say the problem was solved. But
she/he did not go into detail about her solution. E.g., How to set up
a real sender address on the SMTP virtual server? She/He did not
explain it.

Also, it looks like that she/he was using smarthost, which to my
understanding, is sending mail through a remote SMTP server provided by
some ISP. That would be a different story from what I am trying to
solve.

Here is that post:

http://groups.google.com/group/micr...server+configuration+&rnum=1#9675868e46c5729c

From: Leszek - view profile
Date: Tues, Sep 9 2003 7:39 am
Email: "Leszek" <[email protected]>
Groups: microsoft.public.inetserver.iis

Thank you very much.
There were several problems with my IIS configuration (smart host, smtp
server name etc). Moreover it turned out that I needed to set up a real
sender address (From: field) to enforce the IIS to send emails. Strange
but now it works perfectly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,149
Members
46,695
Latest member
StanleyDri

Latest Threads

Top