Send email from gmail using Telnet

∥☆過路亽.° 提交于 2019-12-01 23:30:30

smtp.gmail.com requires TLS. The basic telnet client that comes with windows does not know how to negotiate TLS with a server. You may want to use openssl instead, which is able to negotiate TLS. See http://www.madboa.com/geek/openssl/#cs-smtp for an example of how to do this.

Put into a VBS file, ie sendmail.vbs.

Set emailObj      = CreateObject("CDO.Message")
emailObj.From     = "cat@gmail.com"

emailObj.To       = "cat@gmail.com"

emailObj.Subject  = "Test CDO"
emailObj.TextBody = "Test CDO"

emailObj.AddAttachment "c:\windows\win.ini"

Set emailConfig = emailObj.Configuration

emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
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/smtpusessl")      = true 
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername")    = "cat"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword")    = "Ccat1"
emailConfig.Fields.Update

emailObj.Send

If err.number = 0 then Msgbox "Done"

At Google's web site for GMail you have to turn this feature on for CDO to work.

At your Gmail page click Settings - Accounts and Import - Other Google Account Settings - [At very bottom of page] Allow less secure apps.

Also from memory you also have to click a link in an email the first time you use it (it's been a few years).

The gmail smtp must use smtp auth before you sending your email. The smtp auth need username and password.

see this link blow if you can read in Chinese. http://linxucn.blog.51cto.com/1360306/837365

Last I sugguest you use java to ask gmail smtp server to send email, It will be more easy , becasue you needn't encode the smtp auth to BASE64 or anything else.

GOGOGO, good luck :)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!