南通网站建设系统方案,wordpress老站开启多站点,临海响应式网站设计,可以免费申请试用的网站在Delphi中使用indy SMTP发送gmail邮件[转] 2012-01-01 22:44:30| 分类#xff1a; Delphi | 标签#xff1a; |举报 |字号大中小 订阅 在Delphi中发送email很简单#xff0c;发送ssl方式的gmail邮件也很简单#xff0c;只要在使用的idSMTP上附加一个TIdSSLIOHandlerS… 在Delphi中使用indy SMTP发送gmail邮件[转] 2012-01-01 22:44:30| 分类 Delphi | 标签 |举报 |字号大中小 订阅 在Delphi中发送email很简单发送ssl方式的gmail邮件也很简单只要在使用的idSMTP上附加一个TIdSSLIOHandlerSocket 就可以了。 使用控件 procedure sendMail(sToMail, sSubject, sContent: String); var SMTP: TIdSMTP; MailMessage: TIdMessage; SSLSocket: TIdSSLIOHandlerSocket; begin SMTP : TIdSMTP.Create(nil); SSLSocket : TIdSSLIOHandlerSocket.Create(nil); MailMessage: TIdMessage.Create(nil); SMTP.IOHandler : SSLSocket; SMTP.Port : 465; SMTP.Host : smtp.gmail.com; SMTP.AuthenticationType : atLogin; smtp.UserName : SunnyYu2000; smtp.Password : xxxxxx; // 设置邮件的信息 MailMessage.From.Address : SunnyYu2000gmail.com; MailMessage.Recipients.EMailAddresses : sToMail; MailMessage.Subject : sSubject; MailMessage.Body.Text : sContent; //发送邮件 try try SMTP.Connect(1000); SMTP.Send(MailMessage); ShowMessage(发送成功); except on E:Exception do ShowMessage(发送失败: E.Message); end; finally if SMTP.Connectedthen SMTP.Disconnect; end; MailMessage.Free; SSLSocket.Free; SMTP.Free; end; 编译后需要SSL动态库支持支持库可以到Indy网站上下载到。 如果需要发送附件可以再发送前添加如下类似代码 // 添加邮件的附件 TIdAttachment.Create(MailMessage.MessageParts, sAttachmentFileName); ————– Indy需要的SSL支持dll下载地址 http://www.indyproject.org/Sockets/SSL.EN.aspx 转载于:https://www.cnblogs.com/honeynm/p/4196087.html