1

I am trying to use CDO to send e-mail through a Volusion Windows server. The ASP script I've written works fine on a GoDaddy Windows server so I know the script is correct but it doesn't work through Volusion. In that script, I had used GoDaddy's relay-hosting.secureserver.net SMTP server to send the e-mail and it worked great on the GoDaddy server but not on Volusion.

I've tried several SMTP servers. Volusion provides documentation on their mail servers here:

https://support.volusion.com/article/connecting-my-volusion-e-mail-account

I've tried both the SMTP servers with SSL and without in the script (and have also tried all the different ports).

I'm wondering if the ability to send e-mails with CDO is not supported on Volusion servers? Is there a way to check if a server supports CDO without having access to the cPanel, WHM or any core files? With Volusion, they only give you access to part of the FTP.

Thanks for your help!

EDIT

Here is the code I used that worked:

<%
sendUrl="http://schemas.microsoft.com/cdo/configuration/sendusing"
smtpUrl="http://schemas.microsoft.com/cdo/configuration/smtpserver"

' Set the mail server configuration
Set objConfig=CreateObject("CDO.Configuration")
objConfig.Fields.Item(sendUrl)=2
objConfig.Fields.Item(smtpUrl)="relay-hosting.secureserver.net"
' Server port (typically 25)
objConfig.Fields.Update

' Create and send the mail
Set myMail=CreateObject("CDO.Message")
' Use the config object created above
Set myMail.Configuration=objConfig
myMail.From="test@test.com"
myMail.To="test@test.com"
myMail.Subject = "Test Subject"
myMail.HTMLBody = "Test"
myMail.Send                 

Set myMail = Nothing

response.write "Success!!"
%>

I've obviously updated those e-mail address when I run the code.

EDIT

To answer a question in the comments my server version is:

Microsoft-IIS/6.0

Calon
  • 4,174
  • 1
  • 19
  • 30
MillerMedia
  • 3,651
  • 17
  • 71
  • 150
  • Can you create `Server.CreateObject("CDO.Message")`? If you can the CDO is registered for COM and can be used through [tag:asp-classic]. – user692942 May 08 '14 at 18:06
  • You need to edit your question and post the code you are using. – user692942 May 08 '14 at 18:10
  • Hi @Lankymart, I've just put the code above that I used successfully for reference. – MillerMedia May 08 '14 at 19:24
  • So you say it doesn't work, in what way? Do you get an error or is the e-mail never sent for example? – user692942 May 08 '14 at 19:48
  • Yes, it doesn't work on Volusion. The exact code works on my GoDaddy Windows server but not when I try it on a Volusion server. I get a 500 Internal Server error on that. Is there any chance that their servers aren't configured for it or are blocking it? Is there any way I can get more detailed error logging on something like this? – MillerMedia May 08 '14 at 22:15
  • 1
    Code looks fine (although I would specifically set that mail server port to 25 and use Server.CreateObject in lieu of CreateObject). Any idea which windows server version / IIS version you are on ? (Try outputting Request.ServerVariables("SERVER_SOFTWARE") if you don't) Also, as Lankymart suggested, try finding the exact point of failure by using error handling (On error resume next + if err.number <> 0 then : response.write err.number & " - " & err.Description : end if) – AardVark71 May 09 '14 at 07:48
  • My guess would be the `myMail.Send` will be triggering an error so try `On Error Resume Next` before it and `If Err.Number <> 0 Then Response.Write Err.Number & " - " & Err.Description : Response.Flush` (*you don't need the `End If` if the `If` statement is on one line*) then on the next line `On Error Goto 0`. That should give you some idea of the issue as @AardVark71 suggests. – user692942 May 09 '14 at 09:10
  • @AardVark71, I've updated my question with the server version (Microsoft-IIS/6.0). I've also explicitly added the port to the code which didn't fix the problem unfortunately. Do Windows servers work like PHP servers where you have certain 'extensions' that can be installed on a server? I'm wondering if it's just not supported? – MillerMedia May 12 '14 at 07:41
  • @Lankymart, I tried that error handling (great idea) and unfortunately it still gave me a 500 error. The only time I could get the error messaging to work was when I placed `On Error Resume Next` before the `Set objConfig` line. The error was 'Object Required'. I'm assuming that's because there wasn't anything on the page for the code to read? Are there any other ways to do error handling in this sense since something is obviously breaking the code? As I mentioned, this code worked fine a different Windows server I was using. – MillerMedia May 12 '14 at 07:43
  • @MxmastaMills IIS6 indicates you're on a W2K3 server. That one normally has CDOsys and yet your error indicates either cdosys is not on that server or you do not have permissions for it. Ask your server admin if CDOSYS is available on your server. – AardVark71 May 12 '14 at 08:11
  • Did you use `Server.CreateObject` in place of `CreateObject` as @AardVark71 suggested? It's either that or it doesn't recongnise `CDO.Configuration` progid, which likely means it isn't registered on the host server. – user692942 May 12 '14 at 08:28

2 Answers2

2

To answer your initial question, how to check CDO is supported.

Here is a quick example of checking for the Object Required error (or any error for that matter while instantiating the CDO COM object.

Dim cdo, is_cdosupported

On Error Resume Next
Err.Clear
Set cdo = Server.CreateObject("CDO.Configuration")
is_cdosupported = (Err.Number <> 0)
On Error Goto 0

If is_cdosupported Then
  Call Response.Write("CDO is supported")
Else
  Call Response.Write("CDO not supported")
End If

Digging around on Google

After commenting a few times decided to dig into Volusion (must admit not one I've come across and after a quick search in Google found this link.

Quote from The VSMTP Key

A special ASP class is provided for use with Volusion's built-in send-mail component, VSMTP.

You can use this class to create your own send mail solutions for your store using ASP. Note that the information being provided in this article is intended for advanced users. This solution provides an alternate to sending email via Volusion's standard POP-based or webmail-based solutions.

If you're using Volusion's standard email hosting resources (POP, IMAP, or Webmail), you will not be required to update any functions within your store or my.volusion.com account.

To use the VSMTP component with your Volusion store, you will need to download Volusion's VSMTP ASP class.

Judging by the Object Required ASP component error you get when trying to instantiate the CDO components I would say that CDO is not supported by Volusion servers.

There is a simple example shown using the VSMTP ASP class

<%
Dim mailer
Set mailer = new vsmtp
mailer.VsmtpKey = "65539C7A-525C-4CB7-B36B-BFBBDD332DD6"
mailer.EmailSubject = "Test Subject"
mailer.EmailFrom = "test@testdomain.com"
mailer.EmailTo = "test@testdomain.com"
mailer.TextBody = "Hello World!"
mailer.HTMLBody = "Hello World"
mailer.AddAttachment Server.MapPath("/v/test1.txt")
mailer.AddAttachment "/v/test2.txt"
mailer.Send()
%>

Your best bet is to adapt your existing script to use this VSMTP bespoke class that is support by Volusion.

Looking at the VSMTP ASP class, it looks like it's a simple wrapper to POST to an ASP endpoint (vsmtp.asp).

<%
Class vsmtp
    Public VsmtpKey
    Public EmailSubject
    Public EmailFrom
    Public EmailTo
    Public TextBody
    Public HTMLBody
    Private Attachment
    Private AttachmentFolder
    Public Sub AddAttachment(ByRef FilePath)
        If AttachmentFolder = "" Then
            AttachmentFolder = Server.MapPath("/v")
        End If
        If StrComp(Left(FilePath,Len(AttachmentFolder)),AttachmentFolder,vbTextCompare) = 0 Then
            FilePath = Replace(Mid(FilePath,Len(AttachmentFolder)-1),"\","/")
        End If
        If StrComp(Left(FilePath,3),"/v/",vbTextCompare) <> 0 Or InStr(FilePath,",") > 0 Then
            Err.Raise 512, "vsmtp.AddAttachment", "Invalid Attachment Path"
        End If
        If IsEmpty(Attachment) Then
            Attachment = FilePath
        Else
            Attachment = Attachment & "," & FilePath
        End If
    End Sub
    Public Sub Send()
        Dim HTTPRequest
        Set HTTPRequest = CreateObject("WinHTTP.WinHTTPRequest.5.1")
        HTTPRequest.Open "POST", "http://" & Request.ServerVariables("LOCAL_ADDR") & "/vsmtp.asp", False
        HTTPRequest.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
        HTTPRequest.SetRequestHeader "Host", Request.ServerVariables("SERVER_NAME")
        HTTPRequest.Send _
            "VsmtpKey=" & Server.URLEncode(VsmtpKey) &_
            "&Subject=" & Server.URLEncode(EmailSubject) &_
            "&FromEmailAddress=" & Server.URLEncode(EmailFrom) &_
            "&ToEmailAddress=" & Server.URLEncode(EmailTo) &_
            "&Body_HTML=" & Server.URLEncode(HTMLBody) &_
            "&Body_TextOnly=" & Server.URLEncode(TextBody) &_
            "&Attachment_CSV=" & Server.URLEncode(Attachment)
        If HTTPRequest.ResponseText <> "True" Then
            Set HTTPRequest = Nothing
            Err.Raise 8, "vsmtp.Send", "Unable to send email. Check logs for details."
        End If
        Set HTTPRequest = Nothing
    End Sub
End Class
%>
user692942
  • 16,398
  • 7
  • 76
  • 175
  • Ah wow, I never came across that article and still can't even when I Google. I must not have known the correct search terms. I'm looking through this now. Just curious, what did you search to find that article? – MillerMedia May 12 '14 at 20:46
0

Short answer, you cannot. You will get an error message that states Access is denied. VSMTP is the only alternative to sending email directly from Volusion, however, you can only send from their SMTP servers and the options (e.g. Headers) are limited to what is provided.

Carson Reinke
  • 713
  • 5
  • 16