CDOSYS : how to check if it's working? - asp-classic

On a client server, we have a little script that send an email at the end of an order, just before closing it.
Until yesterday everything works fine, but suddenly, the page gives a generic 500 error.
so I start from the bottom of the page find that if I put a response.end just before the .send of the cdo mail function, the page works fine:
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
Flds(cdoSendUsingMethod) = cdoSendUsingPort
Flds(cdoSMTPServer) = "mail.theserver.com"
Flds(cdoSMTPServerPort) = 25
Flds(cdoSMTPAuthenticate) = cdoAnonymous '0
Flds.Update
With iMsg
Set .Configuration = iConf
.To = "mymail#mail.com"
.From = "amail#mail.gov"
.Sender = ""
.Subject = "test"
.HTMLBody = "TEST"
RESPONSE.END()
.Send
End With
On the page there are also two lines at the beginning:
<!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows 2000 Type Library" -->
<!--METADATA TYPE="typelib" UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library" -->
Well, I’ve already done some test putting some script to send emails a little different from this one but nothing seems to work. Does anybody know a way to test the cdosys? Something that. I don't know, return the version... or a list of options... well, something that makes me know that the error is on the server (and so I could phone to them and tell "hey it's not my fault")...?
Edit:
Since the page gives only a 500 error, is there a way to makes the server returns a more specific error code? i can't access the server, but only the ftp (so only classic asp)
Edit 2: i have add this code:
on error resume next
.Send
If Err.Number <> 0 Then
Response.write(Err.Number)
response.write("<br>")
response.write(Err.description)
end if
and it gives this message:
-2147220975
Impossibile inviare il messaggio al server SMTP. Codice errore di trasporto: 0x800ccc6f. Risposta del server: 554 Your access to this mail system has been rejected due to the sending MTA's poor reputation.

Based on your error message the CDO component is working but your SMTP sever (MTA) is rejecting the message. Maybe because of the .gov domain? Regardless you have a poor SMTP reputation for spamming. You need to use a different SMTP server. If you are using the ip of the IIS server, than that IP is no longer good, and has been blacklisted by spam servers.
Mailchimp has a lot of information on mail deliverable. Take a look at it.
You can use a hosted SMTP service (mailgun, sendgrid, mandrill), all of which will block you right away if you are spamming.

Related

VBScript ASP and Paypal IPN problems

Dear Mentors and Gurus,
My question is basic, it is similar to other IPN questions on here, but I have yet to see an answer related to VBScript (seems PHP is a bit lower level so more work to do to post the response properly- or so I think).
I'm using the PayPal sample code for ASP/VBScript to create a IPN listener. Using the Paypal simulator, I make a call to my script. I don't seem to be able to get a "VERIFIED" response from Paypal, always 'INVALID'. I've read a number of things on the internet (like the charset) and tried these with no progress. Answers regarding charset differences seem to be older as I don't see any place to control charset, especially via the simulator. I'm not seeing a URL Encoding issue as what is posted back is still/already encoded (the GMT + issue doesn't seem to be present as described in other IPN problems).
I post to https://www.paypal.com/cgi-bin/webscr (see code) and that gives me a handshake, but posts to sandbox (commented out) do not result in handshake. Absolutely, Paypal is communicating with my website, I have modified the code to dump out all the form values received into a text file. Just can't ever get a "VERIFIED" response.
I thought the code provided on GitHub would be 'ready to go'. What noobie thing am I missing?
<%#LANGUAGE="VBScript"%>
<%
Dim Item_name, Item_number, Payment_status, Payment_amount
Dim Txn_id, Receiver_email, Payer_email
Dim objHttp, str
' read post from PayPal system and add 'cmd'
' post back to PayPal system to validate
'set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
'set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP.4.0")
set objHttp = Server.CreateObject("Microsoft.XMLHTTP")
str = Request.Form & "&cmd=_notify-validate"
objHttp.open "POST", "https://www.paypal.com/cgi-bin/webscr", false
'objHttp.open "POST", "https://www.sandbox.paypal.com/cgi-bin/webscr", false
'objHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"
'objHttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
objHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objHttp.Send str
' assign posted variables to local variables
'Dim responseText : responseText = objHttp.responseText
Item_name = Request.Form("item_name")
Item_number = Request.Form("item_number")
Payment_status = Request.Form("payment_status")
Payment_amount = Request.Form("mc_gross")
Payment_currency = Request.Form("mc_currency")
Txn_id = Request.Form("txn_id")
Receiver_email = Request.Form("receiver_email")
Payer_email = Request.Form("payer_email")
Dim Folderpath, fs, fPayPal, fPP, FormArray, FormStr
Set fs = CreateObject("Scripting.FileSystemObject")
Folderpath=server.mappath(".\mdb")
fPayPal=Folderpath &"\paypal.txt"
'Payer_email = "test#test.com"
Response.Write "File:" & fPayPal
Set fPP = fs.CreateTextFile(fPayPal,True)
fPP.WriteLine("PayPal")
fPP.WriteLine(str)
FormArray = Split(str, "&", -1, 1)
for each FormStr in FormArray
fPP.WriteLine(FormStr)
Next
' Check notification validation
if (objHttp.status <> 200 ) then
' HTTP error handling
'Response.Write "Error:"
fPP.WriteLine("Status <> 200")
elseif (objHttp.responseText = "VERIFIED") then
fPP.WriteLine("VERIFIED")
fPP.WriteLine(Payer_email)
' check that Payment_status=Completed
' check that Txn_id has not been previously processed
' check that Receiver_email is your Primary PayPal email
' check that Payment_amount/Payment_currency are correct
' process payment
elseif (objHttp.responseText = "INVALID") then
' log for manual investigation
' Response.Write "INVALID"
fPP.WriteLine("INVALID")
else
' Response.Write "OTHER ERROR"
fPP.WriteLine("OTHER ERROR")
end if
set objHttp = nothing
fPP.Close
Set fs=nothing
%>
Things you see commented out are things I tried or comments from the original code on github. Paypal IPN example code
Here's what the result is in paypal.txt, the file written by the code. The last line is "INVALID" which is written because the responseText is set to "INVALID" by the POST call to paypal.
PayPal
payment_type=instant&payment_date=Mon%20Apr%2003%202017%2010%3A12%3A36%20GMT-0400%20%28Eastern%20Daylight%20Time%29&payment_status=Completed&address_status=confirmed&payer_status=verified&first_name=John&last_name=Smith&payer_email=buyer#paypalsandbox.com&payer_id=TESTBUYERID01&address_name=John%20Smith&address_country=United%20States&address_country_code=US&address_zip=95131&address_state=CA&address_city=San%20Jose&address_street=123%20any%20street&business=seller#paypalsandbox.com&receiver_email=seller#paypalsandbox.com&receiver_id=seller#paypalsandbox.com&residence_country=US&item_name1=something&item_number1=AK-1234&tax=2.02&mc_currency=USD&mc_fee=0.44&mc_gross=12.34&mc_gross_1=12.34&mc_handling=2.06&mc_handling1=1.67&mc_shipping=3.02&mc_shipping1=1.02&txn_type=cart&txn_id=283858647&notify_version=2.1&custom=xyz123&invoice=abc1234&test_ipn=1&verify_sign=AFcWxV21C7fd0v3bYYYRCpSSRl31A4bCrzfIB.qeXiXSypZmZAhKwWUC&cmd=_notify-validate
payment_type=instant
payment_date=Mon%20Apr%2003%202017%2010%3A12%3A36%20GMT-0400%20%28Eastern%20Daylight%20Time%29
payment_status=Completed
address_status=confirmed
payer_status=verified
first_name=John
last_name=Smith
payer_email=buyer#paypalsandbox.com
payer_id=TESTBUYERID01
address_name=John%20Smith
address_country=United%20States
address_country_code=US
address_zip=95131
address_state=CA
address_city=San%20Jose
address_street=123%20any%20street
business=seller#paypalsandbox.com
receiver_email=seller#paypalsandbox.com
receiver_id=seller#paypalsandbox.com
residence_country=US
item_name1=something
item_number1=AK-1234
tax=2.02
mc_currency=USD
mc_fee=0.44
mc_gross=12.34
mc_gross_1=12.34
mc_handling=2.06
mc_handling1=1.67
mc_shipping=3.02
mc_shipping1=1.02
txn_type=cart
txn_id=283858647
notify_version=2.1
custom=xyz123
invoice=abc1234
test_ipn=1
verify_sign=AFcWxV21C7fd0v3bYYYRCpSSRl31A4bCrzfIB.qeXiXSypZmZAhKwWUC
cmd=_notify-validate
INVALID
This response is only available when I post to paypal. Posting to sandbox.paypal.com does not indicate a 'sent' or a 'handshake'. I am using a remote/hosted website by a service provider, so the weblogs are not available to me until 48 hours later. All the nice debug features I normally would have on my local webserver are not available (no method to sniff the raw data posted by Paypal or returned that I am aware of on the remote machine).
I found this as a statement:
When you use the PayPal IPN Simulator, the response you get will always be Invalid.
Not in the documentation from what I can tell. If someone can confirm, then this tidbit would have saved me a weekend of trial/error.
//Update
I have learned two things which I'll share with the community. The proper URLs to use in 2017 are:
objHttp.open "POST", "https://ipnpb.sandbox.paypal.com/cgi-bin/webscr", false
or for live:
objHttp.open "POST", "https://ipnpb.paypal.com/cgi-bin/webscr", false
What I believe the issue to be is that the Sandbox URL as of NOW only allows TLS 1.2 HTTPS connections (for sure you must use HTTPS and no longer HTTP). The live paypal URL will required TLS 1.2 in June 2017.
This problem occurs at the objHttp.Send str. It generates a 800c0005 500 error in your ASP as the Paypal Sandbox URL refuses the connection due to server using TLS 1.0 and Paypal requiring TLS 1.2.
As it turns out Godaddy (https://www.godaddy.com) hosting does not allow TLS 1.2 if you are an "older customer". We started windows webhosting with them in 2009. Rather than updating the server underneath our hosting to be current, as we're paying a service, they consider that we fractionally bought the 'old server' and are stuck with that. Now we need to pay to upgrade. This is despite the monthly cost for a new customer for hosting on a normal up-to-date server actually being lower than what we have now.
Please be aware community. I spent a week of time on this. You can't see the HTTPS handshake so a user is not going to know the limitations of the provider.
CONFIRMED. Worked once going onto a new (2017) server which supports TLS 1.2. Needed to start a new web-hosting because Godaddy will not update your existing account or the server software/OS underneath the website you have.

Why emails are getting stuck in pick-up folder when sending through SMTP Service and CDO?

I'm programming Classic Asp with IIS8.5, so for sending email I use the SMTP Service (not the SMTP Server) with the CDO component. I want to send email using the pickup directory option:
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
So my code is:
Set objConfig = Server.CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields
With Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp-relay.gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xxx#gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "The-pwd-123"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") ="C:\inetpub\correos\"
.Update
End With
Set objMessage = Server.CreateObject("CDO.Message")
Set objMessage.Configuration = objConfig
With objMessage
.BodyPart.Charset = "unicode-1-1-utf-8"
.To = "YYY <yyy#gmail.com>"
.From = "XXX <xxx#gmail.com>"
.Subject = "This is a subject"
.TextBody = "This is the body of the message"
.Send
End With
As you may know IIS8.5 come without SMTP Server, so there is no folder for the pickup directory (or I haven't found it yet), you must created, the problem I'm having is that the emails are getting stuck into the folder I created for that purpose.
https://support.google.com/a/answer/176600?hl=es
When you use the cdoSendUsingPickup option, you are simply writing the email message to a file which will be queued up for delivery asyncronously from your code. Yes, this is dramatically faster as your code does not have to wait for the SMTP server to receive the message. So, when using this option, you do not need to specify the destination SMTP server, the port, the username, password, etc.
Hopefully you are now asking yourself how does the server know where to send the message to if I don't specify a forwarding SMTP server. Well, that's because you just have to configure the Microsoft SMTP Service to let it know what server to hand off the messages to. There are plenty of articles online to configure it so you should not have any trouble finding that.

Classic ASP - Sending Email To Own Domain with CDOSYS fails

I have a classic asp email script that uses authenticated CDOSYS to send to emails from a database. It's running on a Parallels Plesk Windows 2008 server.
This works fine for all email addresses except for any addresses that belong to sites on the server I am sending from.
I could authenticate using a Google Apps email account (the domain is set up using Google Apps for email) BUT I would run up against Google' 24 hour sending limits each time the client ran the script.
Can anyone point out where I'm going wrong or explain why email to sites on the sending server causes an error? The error is
error '8004020f'
/admin/send-group-email.asp, line 128
which is the objCDO.Send line
The Code :
(primarydomain.com is the domain name of the primary account the site lives under in Parallels. The SenderEmail value would be, for example, id#secondarydomain.com)
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "localhost"
.Item(cdoSMTPAuthenticate) = 1
.Item(cdoSendUsername) = "authenticate#primarydomain.com"
.Item(cdoSendPassword) = "thepassword"
.Update
End With
while (NOT RS_Emails.EOF)
Dim objCDO
set objCDO = Server.CreateObject("CDO.Message")
objCDO.Configuration = cdoConfig
objCDO.From = CStr(Request.Form("SenderEmail")) & " (" & CStr(Request.Form("SenderName")) & ")"
objCDO.To = RS_Emails.Fields.Item("email").Value
objCDO.Subject = CStr(Request.Form("Subject"))
objCDO.HTMLBody = message
objCDO.Send
set objCDO = Nothing
RS_Emails.MoveNext
Wend
set cdoConfig=Nothing
This is most likely a server issues which can be solved with Plesk.
Please look at the following link:
http://mkb-training.com/index.php?option=com_content&view=article&id=1:setting-up-google-apps-with-plesk&catid=1:google-tutorial&Itemid=2
Pay attention to the following:
"Uncheck the MX1: "Domain IP also used for mail server"" (there are screenshots there on how to do this). I am not 100% sure about Plesk, but in H-Sphere (another Parallels control panel) doing this is essential for being able to send from the server to your own domain when you have a remote mail exchanger.
Also make sure that no MX records point to your server (even if the Google Apps ones are configured correctly).

How do you send an attachment with cdo.message if the file is in use

I am trying to send an email in classic asp site with an attachment. I am recieving the error "The process cannot access the file because it is being used by another process. "
The file is sitting in a shared folder on the same physical server that is hosting the site. If I check in computer management on the server I can confirm that a user has it open.
My question then is: Am I able to send a copy of the file that is saved to disk using cdo.message if that file is in use? I stripped away the rest of my code to do a test and I was still getting the same error using this.
'Create the Message Object
Set objMsg = Server.CreateObject("CDO.Message")
'Set the properties of the Message
With objMsg
Set .Configuration = cdoConfig
.From = sFrom
.To = sTo
.Subject = sSubject
.TextBody = sBody
.Send
End With
No you can't circumvent this restriction nor would you want to else you could be sending a corrupt file.

Classic ASP, Sending E-mail on windows server 2008 - error '8004020f'

I am trying to send e-mail with classic ASP (I am stuck with an old app so I have to use classic ASP here) on Windows Server 2008 R2, IIS 7.5.
I guess lots of thing change from win server 2003 to 2008. I am using the following code but I am getting this error (BTW, error message is so "informative");
error '8004020f'
/poo.asp, line 32
Here is the code;
<!--
METADATA
TYPE="typelib"
UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"
NAME="CDO for Windows 2000 Library"
-->
<%
'Declare variables
Dim sch, cdoConfig, cdoMessage
sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "mail.example.com"
'Set SMTP port which is 25 by default
.Item(sch & "smtpserverport") = 587
.Update
End With
Set cdoMessage = CreateObject("CDO.Message")
With cdoMessage
Set .Configuration = cdoConfig
.From = "info#example.com"
.To = "me#example2.com"
.Subject = "Sample CDO Message"
.TextBody = "This is a test for CDO.message"
.Send
End With
Set cdoMessage = Nothing
Set cdoConfig = Nothing
Response.write "<HTML><head><title>A message has been sent.</title></head><body>A message has been sent.</body></HTML>"
%>
Also, I just installed Microsoft Exchange Server MAPI Client and Collaboration Data Objects 1.2.1 from http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=1004 into my server but it didn't change anything.
NOTE: I could send e-mail over localhost if it works. doesn't matter.
You might come across the following error:
error '8004020f' The event class for this subscription is in an
invalid partition
This error message comes from cdosys.h, and has nothing to do with any sort of "partition" - it is actually lumped in with other errors in an overloaded message. The error code is actually attributed to the following:
CONST LONG CDO_E_RECIPIENTS_REJECTED = 0x8004020FL
Which means that the e-mail was rejected by the server for some reason. Here are some things you can try to alleviate the problem:
Make sure the SMTP server allows anonymous (non-authenticated) relaying. If your SMTP requires outgoing authentication, see Article #2026.
Check if the problem is specific to the domain name(s) used in the e-mail addresses of the recipients. For example, some users have complained that they can send to users on their own domain only; others have said that they can send to any domain except their own (see Article #2511 for some potential causes and solutions).
It may be simply that the e-mail address is being rejected, but other configuration settings on the SMTP server are preventing the true error message from being relayed propely back to the ASP script ... so verify that the address is valid.
If you have a proxy or firewall, make sure the web server is set up to correctly pass through it, that the SMTP server knows about it, and that the proxy allows access to port 25.
Try using a SendUsing value of 1 (pickup) instead of 2 (port). E.g. the following line:
.Item(cdoSendUsingMethod) = cdoSendUsingPort
Becomes
.Item(cdoSendUsingMethod) = cdoSendUsingPickup
http://classicasp.aspfaq.com/email/why-does-cdo-message-give-me-8004020f-errors.html

Resources