Solved

Problems sending Mail in ASP.NET

Posted on 2009-03-30
9
376 Views
Last Modified: 2013-11-30
I have set up my local SMTP Server to allow relaying to 127.0.0.1 and I have even opened up Port 25 and yet I cannot get mail to send out on my Windwos XP 64-Pit Pro computer.  All of the messages drop into the Pickup folder and then are moved to the Queue folder - where they sit forever.

The messages get to the SMTP server without any issues but they never leave - any ideas?
0
Comment
Question by:ktola
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 52

Expert Comment

by:Ryan Chong
ID: 24025936
is your SMTP Services running and configured correctly?

is the sendusing property set correctly as 1 ?
0
 

Author Comment

by:ktola
ID: 24028492
There is no such option when using the System.Net.Mail class in the .NET 3.5 framework.  I am using the default credentials as follows:
SmtpClient thisClient = new SmtpClient();
thisClient.UseDefaultCredentials = true;
thisClient.Send(thisMessage);
 
<system.net>
    <mailSettings>
      <smtp from="email@address.com">
        <network host="localhost" port="25" password="" userName="" />
      </smtp>
    </mailSettings>
  </system.net>

Open in new window

0
 

Author Comment

by:ktola
ID: 24029016
I have been doing some further testing and I wonder if the fact that I have a multi-homed computer is causing the issues.  When I looked at the properties of the SMTP Server, I noticed that it was reading all three of my network connection - 192.168.1.4, 10,10,90.1 and 10.10.90.4 (I run private connections for database and storage...).
Since the 192 address is the one pointing to the Internet, I enabled that IP to relay but that did not correct the issue - but now I am wondering if this is along the lines of the problem...
0
Get Actionable Data from Your Monitoring Solution

Your communication platform is only as good as the relevance of the information you send. Ensure your alerts get to the right people every time with actionable responses. Create escalation rules that ensure everyone follows the process and nothing is left to chance.

 
LVL 52

Expert Comment

by:Ryan Chong
ID: 24029606
is the port 25 opened?

I'm something like this to send out emails in .NET Framework 3.5:
using System.Net.Mail;
 
//...
 
public static Boolean sendMail(String SenderName, String SenderEmail, String ReceiverName, String ReceiverEmail, String Subject, String Body, Boolean isHTML, String SMTPHost, int SMTPPort, Boolean isAuthenticationNeeded, String SMTPUserName, String SMTPUserPwd)
        {
            try
            {
                SmtpClient sclient = new SmtpClient(SMTPHost, SMTPPort);
                sclient.DeliveryMethod = SmtpDeliveryMethod.Network;
                if (isAuthenticationNeeded)
                {
                    sclient.Credentials = new System.Net.NetworkCredential(SMTPUserName, SMTPUserPwd);
                }
 
                MailMessage mail = new MailMessage();
                mail.Subject = Subject;
                mail.IsBodyHtml = isHTML;
                mail.Body = Body;
                mail.BodyEncoding = System.Text.Encoding.UTF8;
                if (SenderName == "")
                {
                    mail.From = new MailAddress(SenderEmail);
                }
                else
                {
                    mail.From = new MailAddress(SenderEmail, SenderName);
                }
                mail.SubjectEncoding = System.Text.Encoding.UTF8;
                if (ReceiverName == "")
                {
                    mail.To.Add(ReceiverEmail);
                }
                else
                {
                    mail.To.Add(new MailAddress(ReceiverEmail, ReceiverName));
                }
                sclient.Send(mail);
                return true;
            }
            catch (SmtpException)
            {
                return false;
            }
            catch (Exception)
            {
                return false;
            }       
        }

Open in new window

0
 

Author Comment

by:ktola
ID: 24030011
Thank you for the code - I am already using most of those settings.  You can actually set most of those in the web.config file and then use the UseDefaultCredentials option when setting up the SmtpClient - this makes it easier to deploy solutions.
The messages are getting to the SMTP Server but being queued immediately and never transmitting.  My experience suggests that this is a relay issue with the SMTP server but I cannot figure out how to overcome the limitation.  I have no enabled the entire 10,, 192, and 127. subnets to relay and that STILL is not working...
I also do have Port 25 open
0
 
LVL 52

Expert Comment

by:Ryan Chong
ID: 24035330
I'm not that familiar with subnets/relay things.... or do you have a chance to use external SMTP host to send out emails?
0
 

Author Comment

by:ktola
ID: 24035373
I am using the same settings that I use to successfully send out emails on numerous Windows 2003 servers (all using a local SMTP server).  The essence of the settings are to enable relaying for the IP of interest, set the SMTP server to that same IP address and Port 80 and then point the web.config host to that IP address.
On Windows Server 2003 (and 2000), everything works fine - on Windows XP 64-BIt Pro, the email stay in the queue forever...
0
 

Accepted Solution

by:
ktola earned 0 total points
ID: 24188117
For those people who are interested, I finally figured out my issues - here is how to configure IIS and your ASP.NET website:
SMTP Server Settings (i.e. Right-Click on SMTP Server in IIS and select Properties):
  1. Select the Default IP for the Server on the main tab
    1. This is usually the same as the IP Address of the main website
    2. Click on the Advanced button and make sure/change the port to 25
  2. Click on the Relay tab
    1. Click on Authentication and ensure that only Anonymous Access is checked
    2. Click on Connection and ensure that the All Except List Below is selected
    3. Click on Relay and Ensure that the Only The List Below option is selected
      1. Add both 127.0.0.1 and your Default IP Address to the list
  3. Close The SMTP Window
Go into your Web.Config file and make sure you add the following section:

<system.net>
     <mailSettings>
          <smtp from=YourEmail@Email.com>
               <network host="DEFAULT IP ADDRESS" password="" userName=""/>
          </smtp>
     </mailSettings>
</system.net>
The DEFAULT IP ADDRESS should equal the IP Address that you select in Step #1 above.
0
 
LVL 52

Expert Comment

by:Ryan Chong
ID: 24190137
thanks for the sharing, cheers!
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello Friends, My friends and relatives always ask me how to delete all the various types of emails at once in our g-mail  or windows live account.  So I researched this topic to find a unique solution to this query.  Here it is for those who do …
Resolve Outlook connectivity issues after moving mailbox to new Exchange 2016 server
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question