title: Can not send mail using smtp.gmail.com, port 587 from vbs script
body: <p>I am trying to send a mail using a vbs script but it doesn't work. I am using server smtp.gmail.com and port 587. The weir thing is that this works when I change the port to 25. Below is the code I am using:</p>
  
  <pre><code>    SMTPMail "to", "cc", "TEST", "TEST"
  
  
  Function SMTPMail(ByVal sTo, ByVal sCc, ByVal sSubject, ByVal sBody)
  
  
      Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory. 
      Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).
  
      Const cdoAnonymous = 0 'Do not authenticate 
      Const cdoBasic = 1 'basic (clear-text) authentication 
      Const cdoNTLM = 2 'NTLM
  
      Dim objMessage
  
      set objMessage = CreateObject("CDO.Message")
      objMessage.Subject = sSubject
      objMessage.Sender = "sender"
      objMessage.From = "from"
      objMessage.To = sTo
      objMessage.CC = sCc
      objMessage.TextBody = sBody
  
  
      '==This section provides the configuration information for the remote SMTP server.
  
      objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  
      'Name or IP of Remote SMTP Server 
      objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"    
  
      'Server port (typically 25) 
      objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587 
  
      'Type of authentication, NONE, Basic (Base64 encoded), NTLM 
      objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
  
      'Your UserID on the SMTP server 
      objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "username"    
  
      'Your password on the SMTP server 
      objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"    
  
      'Use SSL for the connection (False or True) 
      objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
  
      'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server) 
      objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
  
      objMessage.Configuration.Fields.Update()
      objMessage.Send()
  
  End Function
  </code></pre>
  
  <p>Thank you in advance.</p>