Link to home
Start Free TrialLog in
Avatar of jppinto
jppintoFlag for Portugal

asked on

Send email error

I'm using this code to send and email from a contact form on my page that you can find on the link below. I'm getting this error message:

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

It points to the .Send line of code. What can be the problem? The configuration data of my email account?

jppinto

http://www.caraibas.info/luademel/contacto.asp
<%
		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"
		
		Dim objConfig  ' As CDO.Configuration
		Dim objMessage ' As CDO.Message
		Dim Fields     ' As ADODB.Fields
		Dim FirstName, Email, Message
		
		FirstName = Request.Form("nome")
		Email = Request.Form("email")
		Message = Request.Form("mensagem")
		
		' Get a handle on the config object and it's fields
		Set objConfig = Server.CreateObject("CDO.Configuration")
		Set Fields = objConfig.Fields
		
		' Set config fields we care about
		With Fields
			.Item(cdoSendUsingMethod)       = cdoSendUsingPort
			.Item(cdoSMTPServer)            = "mail.mydomain.pt"
			.Item(cdoSMTPServerPort)        = 25
			.Item(cdoSMTPConnectionTimeout) = 10
			.Item(cdoSMTPAuthenticate)      = cdoBasic
			.Item(cdoSendUserName)          = "username"
			.Item(cdoSendPassword)          = "password"
		
			.Update
		End With
		
		Set objMessage = Server.CreateObject("CDO.Message")
		
		Set objMessage.Configuration = objConfig
		
		With objMessage
			.To       = "myname@mydomain.pt"
			.From     = "rtest@aeiou.pt"
			.Subject  = "Teste enviado em "  & Now() 
			.TextBody = "Mensagem enviada em " & Now() & vbCrLf & "Nome: " & FirstName & vbCrLf & "Email: " & Email & vbCrLf & "Messagem: " & Message
			.Send
		End With
		
		Set Fields = Nothing
		Set objMessage = Nothing
		Set objConfig = Nothing
		%>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jmwheeler
jmwheeler

Use jpaulino's suggestion with one minor modificaiton:

.Host = "domain.com"

should be

.Host = "mail.mydomain.pt"

The point being that the host needs to be the name (or ip address) of the server, not just the domain name.
The problem with the original question may because the username/password is incorrect or your password has expired on the mail server.