Solved

.ASP email send returning 500 - Internal server error IIS

Posted on 2013-07-01
8
3,446 Views
Last Modified: 2013-07-17
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.
0
Comment
Question by:Rossamino
  • 5
  • 3
8 Comments
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39291312
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
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39291315
0
 

Author Comment

by:Rossamino
ID: 39311356
That hasn't fixed anything. What's the service that runs SMTP? Not sure if that's even installed.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39312504
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.
0
 

Author Comment

by:Rossamino
ID: 39326641
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?
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39326778
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.
0
 

Author Comment

by:Rossamino
ID: 39330211
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
0
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 39330266
The_transport_failed_to_connect_to_the_server.

You probably need to authenticate.  Look here http://www.paulsadowski.com/wsh/cdo.htm for the sample.  I copied below, make sure to use your own info.  

Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory. 
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network). 

Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM

Set objMessage = CreateObject("CDO.Message") 
objMessage.Subject = "Example CDO Message" 
objMessage.From = """Me"" <me@my.com>" 
objMessage.To = "test@paulsadowski.com" 
objMessage.TextBody = "This is some sample message text.." & vbCRLF & "It was sent using SMTP authentication."

'==This section provides the configuration information for the remote SMTP server.

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.your.com"

'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic

'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "youruserid"

'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "yourpassword"

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 

'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False

'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

objMessage.Send

Open in new window

0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

803 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