The transport failed to connect to the server.

Discussion in 'Email' started by ainofitz, Feb 8, 2012.

  1. I have tried several combinations of port number, authentication, etc. I always get the same result.


    CDO.Message.1 error '80040213'

    The transport failed to connect to the server.

    /mqtgolf/friday/xsend.asp, line 35



    My code is essentially the example provided by Winhost.




    Dim objMessage
    Dim objConfig
    Dim Flds

    set objMessage = createobject("cdo.message")
    set objConfig = createobject("cdo.configuration")
    Set Flds = objConfig.Fields

    Flds.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"

    ' Passing SMTP authentication
    Flds.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
    Flds.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="[email protected]"
    Flds.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="rarelyused"
    Flds.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 'basic (clear-text) authentication

    Flds.update
    Set objMessage.Configuration = objConfig
    objMessage.To = "[email protected]"
    objMessage.From = "[email protected]"
    objMessage.Subject = "New Task"
    objMessage.fields.update
    objMessage.HTMLBody = "This is a test sent from CDO using smtp authentication."
    objMessage.Send



    Help! (And, yes I know that the user name and password are here. I can change the pw after I get it to work.)
     
    Last edited by a moderator: Oct 14, 2015
  2. Elshadriel

    Elshadriel Winhost Staff

    Port 465 uses SSL. Have you tried sending a message using port 25 or 587?
     
  3. Yes. I tried every port that I found suggested in many forums. The same logic works just fine when I use the Winhost email server to send mail. Unfortunately, when I do that and the receipient is a Gmail account, google appends "SPAM-LOW:" to the subject line. In most cases, I can live with this, but it would be a lot cleaner if I could used smtp.gmail.com to send the email.
     
    Last edited by a moderator: Oct 14, 2015
  4. Problem solved. I added two lines to the code shown above and everything works just fine.

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

    Yee Haw! Now I can use google's email server for all outbound email from my Winhost sites. This is very good. Note that the "SPAM-LOW" message goes away when the email is sent to a gmail account.

    Thus, I have changed the password. If you want to test, use your own gmail account.
     
    Last edited by a moderator: Oct 14, 2015
  5. Google SMTP requires connection over SSL to send mail out from their server, below is a sample to send the mail using .NET built in System.Net.Mail

    or when using CDO component, simply add one line to enable SSL
    **
    Flds.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
    **
    http://support.Winhost.com/KB/a650/how-to-send-email-in-aspnet.aspx
    http://support.Winhost.com/KB/a617/how-to-send-mail-using-cdo.aspx


    <%@ Import Namespace="System.Net" %>
    <%@ Import Namespace="System.Net.Mail" %>

    <script language="C#" runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
    //create the mail message
    MailMessage mail = new MailMessage();

    //set the addresses
    mail.From = new MailAddress("[email protected]");
    mail.To.Add("[email protected]");

    //set the content
    mail.Subject = "This is an email";
    mail.Body = "This is from system.net.mail using C sharp with smtp authentication.";
    //send the message
    SmtpClient smtp = new SmtpClient("smtp.gmail.com");

    NetworkCredential Credentials = new NetworkCredential("[email protected]", "password");
    smtp.Credentials = Credentials;
    smtp.EnableSsl = true;
    smtp.Send(mail);
    lblMessage.Text = "Mail Sent";
    }
    </script>
    <html>
    <body>
    <form runat="server">
    <asp:Label id="lblMessage" runat="server"></asp:Label>
    </form>
    </body>
    </html>
     
    Last edited by a moderator: Oct 14, 2015

Share This Page