asp.net unable to get IIS directory Problem Solving method _ Practical Tips

Source: Internet
Author: User
Tags metabase

If you have a asp.net website that needs to send occasional emails, there may be code that looks much like the following:

Copy Code code as follows:

This is shorthand, not the actual project code
public void Send (string from, string to, string subject, String body)
{
var msgmail = new MailMessage (from, to, subject, body);
Msgmail.isbodyhtml = true;
var server = new SmtpClient ("localhost");
Server. Deliverymethod = Smtpdeliverymethod.pickupdirectoryfromiis;
Server. useDefaultCredentials = true;
Server. Send (Msgmail);
}

It may have worked, but when you switch to or initially deploy to a new Windows 2008 server, you will encounter the error message "Cannot get IIS Pickup directory!"

Now, I often call myself the most powerful system administrator in the world. This is not the direction of my research. I'm not very good at it, but sometimes I have to face and solve these problems in real work to get paid.

1 is the SMTP service installed?

Your Web server may not have an SMTP service installed, so go into service management to determine that the SMTP service is in the list of features. If not, you need to add it up.

2 is SMTP configured?

It is not enough to just determine that the SMTP service is already installed. First of all, when you start the server (I have encountered some of the client software before the installation can send mail, but not after, they restarted the server, and mail Service did not start, it is so simple), make sure that your SMTP service also follow the automatic start. Enter the service, make sure that the SMTP service is there, and that the startup type is automatic.

 

Then, you should configure the SMTP service--To be honest, I don't know much about it, so I don't explain it in detail, but you need to know that SMTP is still part of the IIS6.0, so you can find it in the IIS6.0 admin interface. A quick break, because it may not meet the requirements of a complete qualifying domain for some incoming mail servers, and your server may have only one simple domain name that is strictly restricted, such as "Server15", so in the SMTP attribute, under the Delivery tab, Click the Add button to give the server a truly complete meet the required domain name.

3 is the firewall open?

Some of your actions may conflict with firewalls, so it's a good time to troubleshoot SMTP setup. You can manually send a simple email to yourself by using the Telnet native via port 25. Here's an example to follow.

Copy Code code as follows:

Telnet localhost 25
HELO somehost.com
MAIL from:yourname@somedomain.com
RCPT to:the_to_address@somedomain.com
DATA
Subject:the Subject of the Mail
blah blah blah message body


Click Enter to enter the Outbox if you cannot connect, or if the mail is not delivered, there are other issues that need to be addressed because the firewall does not affect the pickup directory.

4 Whether IIS has permission to obtain metadata ( Pickup directory information )

Here we will encounter the actual error reason-the program you run on the website may not have permission to obtain the IIS metadata (metabase) that holds the pickup directory name, which is usually the cause of the error.

You need to download the IIS 6.0 resource bundle. There's a "metaacl.vbs" script you need to use and I don't need it. [Point I download]

Download and install, then run Metabase Explorer (you can search for it, mine in the "program Files (x86) \iis resources\metabase Explorer" directory). You should add read permissions for the SMTPSVC service in your IIS process (I have added permissions to the IIS_IUSRS group to see if you have permission to work for you in the configuration).

5 whether IIS has permission to write to the pickup directory

This step is only supplemental because you may encounter permissions errors the next time you use a Web site to send mail. At this point, you need to add permissions to the pickup directory for your IIS users (for me, I have added write access to the pickup directory "C:\inetpub\mailroot" for "iis_iuses").

So anyway, to make it work for me, but for any server, it might be because I clicked on some magical, multiple-selection boxes that were key to the program, so if you still have questions or know the answers to those questions, please put them in the comments, as I mentioned, I may have altered some of the places I didn't notice, causing the mail to be sent. If there is any shortage, I will correct it in time.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.