Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

.ASP email send returning 500 - Internal server error IIS

Posted on 2013-07-01
8
Medium Priority
?
3,818 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
[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
  • 3
8 Comments
 
LVL 53

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 53

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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 53

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 53

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 53

Accepted Solution

by:
Scott Fell,  EE MVE earned 2000 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

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

Background Information Recently I have fixed file server permission issues for one of my client. The client has 1800 users and one Windows Server 2008 R2 domain joined file server with 12 TB of data, 250+ shared folders and the folder structure i…
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.
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

688 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