Solved

.ASP email send returning 500 - Internal server error IIS

Posted on 2013-07-01
8
3,315 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
Comment Utility
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
Comment Utility
0
 

Author Comment

by:Rossamino
Comment Utility
That hasn't fixed anything. What's the service that runs SMTP? Not sure if that's even installed.
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
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
Promote certifications in your email signature

Has your company recently won an award or achieved a certification? They'll no doubt want to show it off. Email signature images used to promote certifications & awards can instantly establish credibility with a recipient and provide you with numerous benefits.

 

Author Comment

by:Rossamino
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
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 tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now