Link to home
Start Free TrialLog in
Avatar of Trevor Helps
Trevor Helps

asked on

Attempts to send email using classic ASP often times out

One of our customers has reported sporadic problems when our classic ASP application tries to send an email via CDOSYS to Exchange 2010 (running on Server 2008r2).

Occasionally, the 'SEND' happens immediately but it can sometimes take 30 seconds or more or even timeout ASP (90 seconds).

I use a test_mailer_components.asp page (from Pensaworks) and this exhibits the same problem - all quite random.

However, when run from the webserver (where problems above are happening) a VBS script that uses the same set of directives returns immediately, - every time.

Any ideas?
Avatar of Big Monty
Big Monty
Flag of United States of America image

have you checked out any of the IIS logs or event viewer for when the error occurs?

is the message being sent complex in it's creation?
Avatar of Trevor Helps
Trevor Helps

ASKER

Yes - there's nothing showing up in the logs/eventvwr and the messages are always very simple.
This does not correct the issue.
However, this will help to let you know when it has failed.
I am still learning the script, so there is still a lot that I do not know.

Run this, and see what happens.

<%
myMail.To =  "email@address.net"
myMail.Subject = "Just another test email"
myMail.From = "master@domain.com"

myMail.HTMLBody = "Send something"
result = ""
On Error Resume Next
    result = myMail.Send()
    If Err.Number <> 0 Then result = result & ", error #" & Err.Number & ": " & Err.Description
On Error GoTo 0
If result = "" Then
   Response.Write "Mail sent out successfully"
Else
   Response.Write "There was a Mail Server error.<br />We are sorry for any inconvenience."
   ' This is where you need to catch the issue, and then either
   ' 1 - Re-send out the failed emails
   ' 2 - Possible find some code to find a solution to the issue.
End IF


%>

Open in new window


Wayne
Just just curious what app pool does the site run under? Is it the default one or a custom one?

If there are a lot of sites running on the server it may be worth creating iits own asp pool
Can you post your code for both the ASP script and the VBS script.

Are you using cdoSendUsingPickup ?  I would also use authentication too.  But I think using the pickup directory will do the trick.

https://msdn.microsoft.com/en-us/library/aa563054(EXCHG.80).aspx
http://www.paulsadowski.com/wsh/cdo.htm
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

ASKER CERTIFIED SOLUTION
Avatar of Trevor Helps
Trevor Helps

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
Accepting our own solution as a work around to the issue.