简体   繁体   中英

Sending mail using classic ASP?

I am trying to send mail using classic ASP, but my page contain some error that's why when upload the page it shows the error that :

500 Internal Server Error

This is the code i am using;

<%
Dim smtpserver,youremail,yourpassword,ContactUs_Name,ContactUs_Tel,ContactUs_Email
Dim ContactUs_Subject,ContactUs_Body,Action,IsError

smtpserver = "smtp.gmail.com"
youremail = "xxxxx.yyyyyy@gmail.com"
yourpassword = "password" 

Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message") 
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587 
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1 'Use SSL for the connection
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "aaaaa.bbbbbb@gmail.com"
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
ObjSendMail.Configuration.Fields.Update
ObjSendMail.To = "aaaaa.bbbbbb@gmail.com"
ObjSendMail.CC = "cccccc.dddddd@sunarctechnologies.com"
ObjSendMail.Subject = "Subject"
ObjSendMail.From = "xxxxx.yyyyyy@gmail.com"
ObjSendMail.HTMLBody = "<p>hello</p>"
ObjSendMail.Send
Set ObjSendMail = Nothing 
%>

I don't have any idea of classic asp this is just copy paste code from some other source.

Your code looks correct but I'd check wheter gmail only accepts SSL connections on port 465. I believe port 567 is for TLS connections. Alternatively just try port 25.

This question is similar to yours .

You also really need to be able to see the detailed error messages your application is reporting.

Perhaps use the scripts here instead. http://www.w3schools.com/asp/asp_send_email.asp . This has worked for me.

Assuming you have access to IIS, the first thing I recommend is to activate server side debugging and send errors to browser on in IIS. An error 500 can mean anything form a missing end if to the object not being found. Having a proper error message to work with will help narrow down the source of the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM