Link to home
Start Free TrialLog in
Avatar of Rossamino
Rossamino

asked on

.ASP email send returning 500 - Internal server error IIS

I've copied some pages from our old server to a new one, this page is no longer sending emails and instead is throwing an error.  I expect I haven't set something right with the server/service since it worked before and the code hasn't changed.  Here's the sub that's dieing:

sub send_email(x_subject, x_body, x_to, x_from)
'used for sending mail to a single recipient
      sch = "http://schemas.microsoft.com/cdo/configuration/
    set cdoConfig = CreateObject("CDO.Configuration")
    with cdoConfig.Fields
        .Item(sch & "sendusing") = 2
            .Item(sch & "smtpserver") = "127.0.0.1"
        .update
    end with

    set cdoMessage = CreateObject("CDO.Message")  
    with cdoMessage
        set .Configuration = cdoConfig
        .From = x_from
            .To = x_to
        .Subject = x_subject
        .HtmlBody = x_body
        .Send
    end with
 
    set cdoMessage = nothing  
    set cdoConfig = nothing
end sub

If I comment out the call to the sub there's no error, but it also doesn't send the email, obviously.
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Try logging into the server to see the actual error or turn on errors in iis.

Chances are you just need to send via pick up changing this line

  .Item(sch & "sendusing") = 2

to

  .Item(sch & "sendusing") = 1

The 1 means pickup  http://msdn.microsoft.com/en-us/library/exchange/ms873037(v=exchg.65).aspx

Does your smtp need to user/pass?  I use this site as a sample source http://www.paulsadowski.com/wsh/cdo.htm
Avatar of Rossamino
Rossamino

ASKER

That hasn't fixed anything. What's the service that runs SMTP? Not sure if that's even installed.
If you are getting 500 internal error, that means you do not have detailed errors turned on.  You will need to take care of that, then find the actual error and line number in your code.  Otherwise, I can't really give you any advice other then guesses.

Did you try changing your sendusing to  pickup (1)?

Do you need to authenticate?  great examples here http://www.paulsadowski.com/wsh/cdo.htm

Please get a detailed error and line number and I can help you.
I'm looking at IIS v7.5... When I look at the .ASP Debugging Properties configuration for either the site or the directory everything's set to true except "Log Errors to NT log".  Why is it still throwing 500 instead of something useful?
Can you log into the server and run the page?  There is a setting somewhere that can send the error to the remote client and off the top of my head I can't remember. When I error check, I just log into the server.  If you are on shared hosting, you may need to contact the host service to do this for you.
We're using a virtual server on AWS.

The log file has this to say (sendorderemail.asp is the page that's failing).  The first time is with .Item(sch & "sendusing") = 1 and the second time is with it set to 2:

2013-07-16 15:06:03 10.36.106.179 POST /sendorderemail.asp |97|80040213|The_transport_failed_to_connect_to_the_server.__ 443 - 109.32.157.192 Mozilla/5.0+(Windows+NT+6.1;+WOW64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/28.0.1500.72+Safari/537.36 500 0 0 1664


2013-07-16 15:06:03 10.36.106.179 POST /sendorderemail.asp |97|80040213|The_transport_failed_to_connect_to_the_server.__ 443 - 109.32.157.192 Mozilla/5.0+(Windows+NT+6.1;+WOW64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/28.0.1500.72+Safari/537.36 500 0 0 1664
ASKER CERTIFIED SOLUTION
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial