我的 asp formail 不工作
My asp formail not working
我浪费了将近 2 天的时间来弄清楚。我为我的域名使用 gmail 应用程序付费电子邮件。我试图从网站上发送一个小的联系表格,但不知何故它不起作用,我[没有收到任何电子邮件。下面是我的脚本
<%
dim sEmailContent
sEmailContent = sEmailContent & "Full Name : " & Request.Form("full_name") & vbCrLf
sEmailContent = sEmailContent & "Phone : " & Request.Form("phone") & vbCrLf
sEmailContent = sEmailContent & "Email : "& Request.Form("email") & vbCrLf
sEmailContent = sEmailContent & "Message : "& Request.Form("message")
'Response.Write(sEmailContent)
call send_email(Request.Form("email"),sEmailContent)
function send_email(sToEmail,sEmailBody)
on error resume next
Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message")
'Configuration for remote SMTP server
'Network Send
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name of SMTP server
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="smtp.gmail.com"
'SMTP port
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
'MaxESP SMTP servers require authentication
'Basic Authentication
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
'SMTP username as configured in the control panel
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="bla@domain.com"
'SMTP user password as configured in the control panel
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="blablabla"
ObjSendMail.Configuration.Fields.Update
'Configuration for email message
'Email To address
ObjSendMail.To = "bla@domain.com"
'Email Subject
ObjSendMail.Subject = "Contact Us Query"
'Email From address
ObjSendMail.From = "bla@domain.com"
'Email Body
ObjSendMail.TextBody = sEmailBody
ObjSendMail.Send
Set ObjSendMail = Nothing
response.Redirect("contact-us.html")
if err.number <> 0 then
Response.Redirect("contact-us.html")
end if
on error goto 0
end function
%>
请告诉我我做错了什么?
谢谢
可能有很多事情。
- 托管可能会阻止此操作。可能值得与他们一起开票,以便他们可以追踪发生的事情
- 你确定你没有收到吗?检查本地和邮件服务器上的垃圾邮件箱。我以前遇到过。
- 使用相同的电子邮件地址发送和发送可能会导致问题。尝试不同的电子邮件地址,甚至可能是假的发件人地址,以避免任何 dns 问题
您遇到 ASP 错误了吗?
我浪费了将近 2 天的时间来弄清楚。我为我的域名使用 gmail 应用程序付费电子邮件。我试图从网站上发送一个小的联系表格,但不知何故它不起作用,我[没有收到任何电子邮件。下面是我的脚本
<%
dim sEmailContent
sEmailContent = sEmailContent & "Full Name : " & Request.Form("full_name") & vbCrLf
sEmailContent = sEmailContent & "Phone : " & Request.Form("phone") & vbCrLf
sEmailContent = sEmailContent & "Email : "& Request.Form("email") & vbCrLf
sEmailContent = sEmailContent & "Message : "& Request.Form("message")
'Response.Write(sEmailContent)
call send_email(Request.Form("email"),sEmailContent)
function send_email(sToEmail,sEmailBody)
on error resume next
Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message")
'Configuration for remote SMTP server
'Network Send
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name of SMTP server
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="smtp.gmail.com"
'SMTP port
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
'MaxESP SMTP servers require authentication
'Basic Authentication
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
'SMTP username as configured in the control panel
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="bla@domain.com"
'SMTP user password as configured in the control panel
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="blablabla"
ObjSendMail.Configuration.Fields.Update
'Configuration for email message
'Email To address
ObjSendMail.To = "bla@domain.com"
'Email Subject
ObjSendMail.Subject = "Contact Us Query"
'Email From address
ObjSendMail.From = "bla@domain.com"
'Email Body
ObjSendMail.TextBody = sEmailBody
ObjSendMail.Send
Set ObjSendMail = Nothing
response.Redirect("contact-us.html")
if err.number <> 0 then
Response.Redirect("contact-us.html")
end if
on error goto 0
end function
%>
请告诉我我做错了什么? 谢谢
可能有很多事情。
- 托管可能会阻止此操作。可能值得与他们一起开票,以便他们可以追踪发生的事情
- 你确定你没有收到吗?检查本地和邮件服务器上的垃圾邮件箱。我以前遇到过。
- 使用相同的电子邮件地址发送和发送可能会导致问题。尝试不同的电子邮件地址,甚至可能是假的发件人地址,以避免任何 dns 问题
您遇到 ASP 错误了吗?