
现在我需要使用Gmail帐户发送电子邮件,因此我需要使用TLS.
任何人都可以提供一个简单的样本,如何做到这一点.
谢谢
解决方法 此代码适用于GMail:begin IDSMTP1 := TIDSMTP.Create; IDSSliOHandlerSocketopenSSL1 := TIDSSliOHandlerSocketopenSSL.Create; try with IDSMTP1 do begin Host := srvr.Host; Port := srvr.Port; if (srvr.needAuthentication = 'Y') then AuthType := satDefault else AuthType := satNone; IOHandler := IDSSliOHandlerSocketopenSSL1; if (srvr.secureMode = 'Y') then UseTLS := utUseRequireTLS else UseTLS := utNoTLSSupport; Username := srvr.Username; Password := srvr.Password; end; IDMBHTML := TIDMessageBuilderHTML.Create; IDmessage1 := TIDMessage.Create; try with IDMBHTML do begin enc := TEnCoding.Unicode; HTML.LoadFromStream(FEmlMsg.MsgBody,enc); for c := 0 to FEmlMsg.Attachmnts.Count - 1 do Attachments.Add(FEmlMsg.Attachmnts[c]); FillMessage(IDMessage1); end; with IDmessage1 do begin Subject := FEmlMsg.MsgSubject; From.Address := FEmlMsg.FromAddress; From.name := FEmlMsg.Fromname; RecipIEnts.EMailAddresses := FEmlMsg.RecipIEntAddress; if FEmlMsg.ReceiptRecipIEntAddress <> '' then ReceiptRecipIEnt.Address := FEmlMsg.ReceiptRecipIEntAddress; if FEmlMsg.ReceiptRecipIEntname <> '' then ReceiptRecipIEnt.name := FEmlMsg.ReceiptRecipIEntname; end; with IDSMTP1 do begin if not Connected then Connect; Send(IDMessage1); end; finally IDmessage1.Free; IDMBHTML.Free; end; finally IDSMTP1.Free; IDSSliOHandlerSocketopenSSL1.Free; end;end;总结
以上是内存溢出为你收集整理的使用TLS从DELPHI(Indy)发送SMTP全部内容,希望文章能够帮你解决使用TLS从DELPHI(Indy)发送SMTP所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)