使用SSL连接发送CDO电子邮件
我有一个asp页面,它使用CDO通过电子邮件发送表单的详细信息。到目前为止,我已经通过与hmail服务器的清晰连接使用smtp端口25完成了这项工作 我现在需要使用SSL连接。我已经创建了一个安全证书,并将hmail服务器设置为使用端口465和ssl 然而,由于某些原因,当我尝试发送表单时,我收到一个错误500,并且电子邮件没有发送 我也尝试过587端口,但也不起作用 我使用的CDO代码如下所示:使用SSL连接发送CDO电子邮件,ssl,cdo.message,hmail-server,Ssl,Cdo.message,Hmail Server,我有一个asp页面,它使用CDO通过电子邮件发送表单的详细信息。到目前为止,我已经通过与hmail服务器的清晰连接使用smtp端口25完成了这项工作 我现在需要使用SSL连接。我已经创建了一个安全证书,并将hmail服务器设置为使用端口465和ssl 然而,由于某些原因,当我尝试发送表单时,我收到一个错误500,并且电子邮件没有发送 我也尝试过587端口,但也不起作用 我使用的CDO代码如下所示: If request.Form("submit") <> "" then Set m
If request.Form("submit") <> "" then
Set myMail=CreateObject("CDO.Message")
myMail.Subject="xxxxxxx"
myMail.From=Request.Form("email")
myMail.To= "xxxxxxxxxxx"
myMail.TextBody = "Name:"& Request.Form("name")& vbcrlf & vbcrlf & _
"Email:" & Request.Form("email") & vbcrlf & vbcrlf & _
"Telephone:" & Request.Form("telephone") & vbcrlf & vbcrlf & _
"Location:" & Request.Form("location") & vbcrlf & vbcrlf & _
"Other location:" & Request.Form("other_location") & vbcrlf & vbcrlf & _
"Comments:" & Request.Form("comments")
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
'Name or IP of remote SMTP server
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
="127.0.0.1"
'Server port
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") _
=465
MyMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
myMail.Configuration.Fields.Update
myMail.Send
set myMail=nothing
If request.Form(“submit”)“”则
设置myMail=CreateObject(“CDO.Message”)
myMail.Subject=“xxxxxxx”
myMail.From=Request.Form(“电子邮件”)
myMail.To=“xxxxxxxxxx”
myMail.TextBody=“Name:”&Request.Form(“Name”)&vbcrlf&vbcrlf&_
“电子邮件:”&Request.Form(“电子邮件”)&vbcrlf&vbcrlf&_
“电话:”&Request.Form(“电话”)&vbcrlf&vbcrlf&_
“位置:”&Request.Form(“位置”)&vbcrlf&vbcrlf&_
“其他位置:”&Request.Form(“其他位置”)&vbcrlf&vbcrlf&_
“注释:”&请求表(“注释”)
myMail.Configuration.Fields.Item_
("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
'远程SMTP服务器的名称或IP
myMail.Configuration.Fields.Item_
("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
="127.0.0.1"
'服务器端口
myMail.Configuration.Fields.Item_
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") _
=465
MyMail.Configuration.Fields.Item_
("http://schemas.microsoft.com/cdo/configuration/smtpusessl“”=真
myMail.Configuration.Fields.Update
我的邮件,发送
设置myMail=nothing
有人知道什么是错误的吗
多谢各位 这篇文章有点老了,你已经解决了吗 如果没有,您能否提供错误消息(通用500除外) 我只有2个可能的想法,但没有看到实际的错误消息: 1) 可能是超时了。尝试添加myMail.Configuration.Fields.Item_ ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout”)=60
2) 可能证书与“127.0.0.1”IP地址不匹配,因此SSL通信被拒绝。我在使用旧ASP代码时也遇到了同样的问题。以下代码适用于Amazon。 注意:似乎只有端口25或465工作,并且smtpusessl=1(在VBScript中为True=-1)
如果有人发现这个页面想知道如何使用CDO从Excel发送电子邮件,我会用
' Create Connection
Function GetEmailConnection ()
Set oMail = CreateObject("CDO.Message")
Set GetEmailConnection = oMail
End function
Function GetConfiguration()
Set oConfig = CreateObject("CDO.Configuration")
Set GetConfiguration = oConfig
End Function
' Send Email
Sub SendEmail (subject, fromAddress, toAddress, body)
set objMessage = GetEmailConnection()
Set objConfiguration = GetConfiguration()
Set fields = objConfiguration.Fields
Const cdoSendUsingPort = 2
With fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "email-smtp.us-east-1.amazonaws.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 '
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "user"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
.Update
End With
With objMessage
set .Configuration = objConfiguration
.Subject = subject
.From = fromAddress
.To= toAddress
.TextBody = body
.Send
End With
set objMessage = nothing
end Sub