Question

I can't send email via ASP.NET and sent an email to my web hosts for some help and was told to modify my security settings and was sent a link:

http://forums.asp.net/t/1111145.aspx/1

I've read what it said there and tried setting <trust level="Full" originUrl="" /> in web.config, but then I get the error:

This configuration section cannot be used at this path. This happens when the site administrator has locked access to this section using <location allowOverride="false"> from an inherited configuration file.

I've not set any other web.config file.

So I asked the web hosts again, and asked if it was a server setting which I cannot change, but the response I got was just:

You'll need to specify a more specific path.

Which is lovely, but I've no idea what that means!

Having done a bit more digging I am wondering if I have to set up a separate trust file, is this correct?

Could someone point me in the direction of the correct way to set up my Trust level (I realise "full" is probably incorrect as well?) as I really don't understand what I am supposed to do!

Was it helpful?

Solution

Trust levels are documented here: http://msdn.microsoft.com/en-us/library/ie/wyts434y.aspx. In shared hosting, providers lock that settings, so you cannot change in your web.config. If you clearly requested from your provider to allow full trust to your application, and if they responded with "huh?", then you were talking to an uneducated person - either request escalation or change hosts. "Please configure my application with full trust" should be clear enough. Note that they may not be willing to do that, once they understand your request.

Also, I cannot be sure that full trust is required to send mail out. Sending mail out involves ability to communicate to an SMTP server, and usually web hosts allow accessing only theirs and they block everything else (for spam prevention). You will not be able to talk them into making an exception for you, but if you ask "please tell me which smtp and port to use to send email out from my asp.net application", they should give it to you (otherwise, escalate or change hosts). You actually should have asked them to help you send mail out first, before you made conclusion that trust-level is what's obstructing it (now, I'm pretty sure it doesn't).

Also, read this, please: https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem

OTHER TIPS

Try this:

 public static void ConfirmMail(string emailTo)

{
    try
    {

        MailMessage message = new MailMessage();
        message.Subject = "Account Registration From 91calls";
        message.From = new MailAddress(Convert.ToString("admin@91calls.com"),"Admin");
        message.To.Add(emailTo);
        message.BodyEncoding = System.Text.Encoding.UTF8;
        StringBuilder sb = new StringBuilder();
        sb.Append("<html>");
        sb.Append("<Body>");
        sb.Append("<table cellpadding='0' cellspacing='0' width='100%' border='0'>");
        sb.Append("<tr><td align='center'><table cellpadding='0' cellspacing='0' width='100%' border='0'>");
       // sb.Append("<tr><td align='left'><asp:Image ID='imgLogo' runat='server' ImageUrl='http://supervau.w01.winhost.com/images/logo.png' />");
        sb.Append("</td></tr><tr><td>Hi, <br></td></tr><tr><td align='left'>You are successfylly resgistered with 91 calls.<br>");
        sb.Append("<br>Thank you for using, : http://www.91calls.com<br /><br>For questions or concerns regarding your account, please visit : http://www.91calls.com");
        sb.Append("</td></tr></table></td></tr></table>");
        sb.Append("</Body>");
        sb.Append("</html>");
        message.Body = sb.ToString();
        message.IsBodyHtml = true;
        SmtpClient client = new SmtpClient();
        client.Send(message);


    }
    catch
    {
    }

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top