Меню

Cdo message 1 ошибка 80040213

CDO.Message.1 error '80040213'

The transport failed to connect to the server.

/check.asp, line 25

please help to solve this problem

check this code

<%@ Language=VBScript %>
<html>
<head>
</head>
<body>
<%
dim to_field, message
to_field = Request.Form("to_field")
message = Request.Form("message")
'Create the e-mail server object
Set objCDOSYSMail = Server.CreateObject("CDO.Message")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
'Out going SMTP server
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.example.com"
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objCDOSYSCon.Fields.Update
'Update the CDOSYS Configuration
Set objCDOSYSMail.Configuration = objCDOSYSCon
objCDOSYSMail.From = "admin@example.com" ' the address you want the email to be from
objCDOSYSMail.TO = "anuradha@gmail.com"  'the address the mail is to be sent to
objCDOSYSMail.Subject = "Subject goes here"
objCDOSYSMail.HTMLBody = "fffffffffff"
objCDOSYSMail.Send
'Close the server mail object
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing
%>
<p>Mail sent successfully to address <%=to_field%>!</p>
</body>
</html>

Kenster's user avatar

Kenster

22.1k21 gold badges80 silver badges102 bronze badges

asked Dec 2, 2010 at 8:31

anuradha's user avatar

You need to add your user name and password before sending. This is because you used a value of 2 in the sendusing‘s field. This means you’re using authentication.

'Your UserID on the SMTP server'
objCDOSYSCon.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "yourusername"

'Your password on the SMTP server'
objCDOSYSCon.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "yourpassword"

Jonathan de M.'s user avatar

answered Jun 28, 2011 at 0:40

Yukon's user avatar

YukonYukon

711 silver badge2 bronze badges

Вопрос:

Это действительно только мой второй скрипт VBS, поэтому будьте осторожны… Я сделал что-то, что было лично или связано с компанией. Я уверен, что все эти поля в любом случае верны. SMTP-сервер правильный, я дважды проверил с провайдером, так как это причина номер 1, найденная на других сайтах. Этот скрипт также будет извлекать информацию из определенной ячейки и вставлять ее в тело… Любая помощь будет принята с благодарностью! Также он говорит, что ошибка находится в строке 46, которая является “ObjSendMail.Send”. Все работает, кроме части электронной почты…

    Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message")
Set objExcel = CreateObject("Excel.Application")
StopDate = DateAdd("d", -1 - Weekday(Date), Date)
StartDate = StopDate-13

Dim xlApp
Dim xlWkb
Dim monthEnd
Set xlApp = CreateObject("excel.application")

Set xlWkb = xlApp.Workbooks.Open("******")
xlWkb.RunAutoMacros 1
xlApp.Run ("UpdateAll")
monthEnd = xlApp.cells(2,7).value
xlApp.ActiveWorkbook.SaveAs strSaveFile & "Monthly Revenue Report " & Year(Now) & "." & Month(Now) & "." & Day(Now) & ".xls", 56

xlApp.Quit
Set xlWkb = Nothing
Set xlApp = Nothing

WScript.Sleep 10000
mailSubject = "Monhtly Revenue Report " & PrevMonthName
mailBody = "The Monthly Revenue Report is no ready. Month End: " & monthEnd

ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.office365.com"
ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 240
ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "********"
ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "********"
ObjSendMail.Configuration.Fields.Update

ObjSendMail.To = "*********"
ObjSendMail.Subject = mailSubject
ObjSendMail.From = "*******"
'ObjSendMail.HTMLBody = "this is the body"
ObjSendMail.TextBody = mailBody
ObjSendMail.Send


'Set ObjSendMail = Nothing

Лучший ответ:

В случае сомнений прочитайте документацию. Office365 использует порт представления (587/tcp) для отправки почты. Замените это:

ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

с этим:

ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587

и ошибка должна исчезнуть (при условии, что исходящие подключения к порту 587/tcp разрешены в вашей сети).

Вы можете проверить доступность порта с помощью сканера портов, такого как nmap, scanline или PortQry) или вручную с помощью telnet:

telnet smtp.office365.com 587

Исходные соединения с портом 25/tcp скорее всего блокируются вашим провайдером в качестве меры для предотвращения/уменьшения спама ботнета.

Ответ №1

Следующий код работал для smtp.office365.com. Вы указываете smtpusessl = true, но вы НЕ указываете порт, иначе вы получите ошибку 5.7.57.

    Sub SMPTTest2()
Set emailObj = CreateObject("CDO.Message")

emailObj.From = "name@myaddress.com"
emailObj.To = "name@youraddress.com"
emailObj.Subject = "Test CDO"
emailObj.TextBody = "Test CDO"
'emailObj.AddAttachment "c:windowswin.ini"

Set emailConfig = emailObj.Configuration


emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.office365.com"
'Exclude the following line
'emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "name@myaddress.com"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mypassword"
emailConfig.Fields.Update

emailObj.Send

If Err.Number = 0 Then MsgBox "Done"
End Sub

Ответ №2

У меня есть Windows Server 2003 R2 с IIS и веб-сайт с классическим ASP. Попытка заставить его использовать CDOSYS для электронной почты с помощью нашего собственного (внешнего) размещенного сервера обмена office365.

Я получаю следующую ошибку

CDO.Message.1 error '80040213'
The transport failed to connect to the server.

Обычно это означает одну из трех проблем: 1. Неверный SMTP-сервер / порт 2. Неверный логин / пароль 3. Адрес FROM недействителен согласно SMTP-серверу (неправильный домен)

SMTP-сервер и порт указаны поставщиком правильно. Логин / пароль верны, так как я могу войти в учетную запись электронной почты, используя эти данные. Адрес FROM правильный, поскольку это учетная запись, которую я использую для входа.

Я могу подключиться к серверу обмена по telnet с веб-сервера на этом адресе и порту, поэтому соединение может быть выполнено по крайней мере с сервера.

Так что на данный момент я не понимаю, в чем может быть проблема. Есть ли у кого-нибудь указатели на что-нибудь еще, на что мне нужно взглянуть?

Это конфигурация, которую использует веб-сайт

myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2 
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.office365.com"
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=587
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 20
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "username"
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"

4 ответа

Лучший ответ

Ну, в конце концов, я решил эту проблему. Мне нужно было использовать другой метод подключения к серверу office365. Так что теперь все работает как надо.


0

chenks
2 Янв 2017 в 08:40

Попробуйте Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25

В Office 365 cdo, похоже, предпочитает порт 25 даже при использовании проверки подлинности.

Вот проверенная конфигурация, если она поможет

Set iConfg = Server.CreateObject("CDO.Configuration")
Set Flds = iConfg.Fields
With Flds
        .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.office365.com"
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
        .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "myusername"
        .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mypassword"
        .Update
End With
objMail.Configuration = iConfg


0

John
10 Дек 2016 в 15:15

Пытаться

.Item("http://schemas.microsoft.com/cdo/configuration/smtpsendtls") = 1

Вместо

.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1


0

Robert Columbia
26 Окт 2018 в 04:37

Вы настроили ретранслятор SMTP в Office 365?

От администратора Office 365 перейдите к:

  1. Админ> Обмен
  2. Почтовый поток> Коннекторы
  3. Нажмите добавить новый коннектор ретрансляции SMTP.
  4. Выберите от «почтовый сервер вашей организации» до «office 365».
  5. Дайте соединителю имя и описание
  6. Выберите подтверждение по IP-адресу и добавьте IP-адрес своего веб-сервера.
  7. Сохранить


0

George O’Sullivan
10 Дек 2016 в 13:51

does anyone here have any experience of classic ASP and CDOSYS email?

i posted this over on stackoverflow, but so far not having any luck

I have a Windows Server 2003 R2 running IIS and a website using classic ASP. Trying to get it to use CDOSYS to email using our own (externally) hosted office365 exchange server.

I get the following error

CDO.Message.1 error '80040213'
The transport failed to connect to the server.

Which usually means one of 3 problems: 1. Incorrect SMTP server / port 2. Incorrect login/password 3. FROM address not valid according to SMTP server (wrong domain)

The SMTP server and port are correct according to supplier. The login/password is correct as I can log into the mail account using those details The FROM address is correct as that is the account I am using to log in.

I can telnet to the exchange server from the web server on that address and port, so a connection can be made from the server at least.

So at the moment I’m at a loss as to what the problem might be. Does anyone have any pointers as to anything else I need to look at?

This is the config the website is using

myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2 
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.office365.com"
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=587
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 20
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "username"
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"

things already tried:
port 25 — same error
«Did you setup an SMTP relay in Office 365?» — yes and same error.

I have a Windows Server 2003 R2 running IIS and a website using classic ASP.
Trying to get it to use CDOSYS to email using our own (externally) hosted office365 exchange server.

I get the following error

CDO.Message.1 error '80040213'
The transport failed to connect to the server.

Which usually means one of 3 problems:
1. Incorrect SMTP server / port
2. Incorrect login/password
3. FROM address not valid according to SMTP server (wrong domain)

The SMTP server and port are correct according to supplier.
The login/password is correct as I can log into the mail account using those details
The FROM address is correct as that is the account I am using to log in.

I can telnet to the exchange server from the web server on that address and port, so a connection can be made from the server at least.

So at the moment I’m at a loss as to what the problem might be.
Does anyone have any pointers as to anything else I need to look at?

This is the config the website is using

myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2 
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.office365.com"
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=587
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 20
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "username"
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"

I have a Windows Server 2003 R2 running IIS and a website using classic ASP.
Trying to get it to use CDOSYS to email using our own (externally) hosted office365 exchange server.

I get the following error

CDO.Message.1 error '80040213'
The transport failed to connect to the server.

Which usually means one of 3 problems:
1. Incorrect SMTP server / port
2. Incorrect login/password
3. FROM address not valid according to SMTP server (wrong domain)

The SMTP server and port are correct according to supplier.
The login/password is correct as I can log into the mail account using those details
The FROM address is correct as that is the account I am using to log in.

I can telnet to the exchange server from the web server on that address and port, so a connection can be made from the server at least.

So at the moment I’m at a loss as to what the problem might be.
Does anyone have any pointers as to anything else I need to look at?

This is the config the website is using

myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2 
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.office365.com"
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=587
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 20
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "username"
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"

  • Remove From My Forums
  • Вопрос

  • Hello,

    I have an ASP page that sends emails using CDO objects using HMail server and SSL.

    However, when I try to send an email, I get a  ‘80040213 the transport failed to connect to the server’. I do not know what I am doing wrong.

    The code of the CDO message is below:

    If

    request.Form(«submit») <>
    «»
    thenSet
    myMail=CreateObject(
    «CDO.Message»)

    myMail.Subject=

    «Contact Request»

    myMail.From=Request.Form(

    «email»)

        myMail.To=

    «xxxxxx»

    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») _

        =587

        myMail.Configuration.Fields.Item _

                    (

    «http://schemas.microsoft.com/cdo/configuration/smtpusessl») = 1

        myMail.Configuration.Fields.Item _

        (

    «http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout») = 120

        myMail.Configuration.Fields.Update

        myMail.Send

    set myMail=nothing

Я знаю, что в этом есть много вопросов, но у меня нет ответа, который работает для меня.

Мое приложение ASP Classic, сервер, на котором он работает, — это Windows Server 2000 (очень старый, я знаю), я использую сервер Office365, и я использую информацию, предоставленную Office365, когда я вхожу в систему по электронной почте (порт 587, правильное имя пользователя и пароль, правильный SMTP-сервер, TLS установлен в true).

Я всегда получаю сообщение об ошибке «CDO.Message.1» 80040213 «Транспорт не удалось подключиться к серверу». как сообщение об ошибке, строка, на которую он указывает, является командой.Send.

    Const cdoSendUsingMethod           = "http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSendUsingPort = 2
Const cdoSMTPServer = "http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPort = "http://schemas.microsoft.com/cdo/configuration/smtpserverport"
Const cdoSMTPConnectionTimeout = "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
Const cdoSMTPAuthenticate = "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
Const cdoBasic = 1
Const cdoSendUserName = "http://schemas.microsoft.com/cdo/configuration/sendusername"
Const cdoSendPassword = "http://schemas.microsoft.com/cdo/configuration/sendpassword"
'Use SSL for the connection (False or True)
Const cdoSendTLS = "http://schemas.microsoft.com/cdo/configuration/smtpusessl"

' create CDOSYS objects
Set objCDOSYSMail = Server.CreateObject("CDO.Message")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")

'Set our smtp server
objCDOSYSCon.Fields.Item(cdoSMTPServer) = "smtp.office365.com"
objCDOSYSCon.Fields.Item(cdoSMTPAuthenticate) = cdoBasic
objCDOSYSCon.Fields.Item(cdoSendUserName) = "my.email@email.com"
objCDOSYSCon.Fields.Item(cdoSendPassword) = "password"
'objCDOSYSCon.Fields.Item(cdoSMTPServerPort) = 587
objCDOSYSCon.Fields.Item(cdoSendUsingMethod) = cdoSendUsingPort
objCDOSYSCon.Fields.Item(cdoSendTLS) = True
objCDOSYSCon.Fields.Item(cdoSMTPConnectionTimeout) = 30

objCDOSYSCon.Fields.Update

'Use our new configurations for our mailer
Set objCDOSYSMail.Configuration = objCDOSYSCon

strSpecFile = Application("px683_network_downloads_specs") & strSpecFileName

objCDOSYSMail.From = "to.email@email.com"
objCDOSYSMail.To = "my.email@email.com"
objCDOSYSMail.Subject = "A subject"
objCDOSYSMail.HTMLBody = "Some text for the body"

'Normal level of importance
objCDOSYSMail.Send

set objCDOSYSMail = nothing
set objCDOSYSCon = nothing

Я пробовал с портом 25 без всякой удачи. Если я использую другую почтовую службу, которая вообще не использует SSL (локальная служба, а не Office365), у меня нет проблем (я комментирую usessl и меняю порт на 25). Кроме того, если я пытаюсь использовать другую почтовую службу, которая работает безупречно в приложении ASP.Net, я получаю те же проблемы, эта другая служба электронной почты использует порт 25 и SSL и не является службой Office365.

0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии

А вот еще интересные материалы:

  • Яшка сломя голову остановился исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного где ошибка
  • Cdirectsound idirectsound initialize failed ошибка
  • Cdimport ert 1851 ошибка исполнения метода