DataFlex
DataFlex
Send email using SMTP STARTTLS.
Send email using SMTP STARTTLS. With STARTTLS, the SMTP client connects to the SMTP server on port 25 (non-SSL) and then issues a STARTTLS command to convert the connection to a secure TLS channel.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoMailman
Variant vEmail
Handle hoEmail
String sTemp1
Move False To iSuccess
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// The mailman object is used for sending and receiving email.
Get Create (RefClass(cComChilkatMailMan)) To hoMailman
If (Not(IsComObjectCreated(hoMailman))) Begin
Send CreateComObject of hoMailman
End
// Set the SMTP server.
Set ComSmtpHost Of hoMailman To "smtp.mymailserver.com"
Set ComSmtpUsername Of hoMailman To "myLogin"
Set ComSmtpPassword Of hoMailman To "myPassword"
Set ComStartTLS Of hoMailman To True
// Create a new email object
Get Create (RefClass(cComChilkatEmail)) To hoEmail
If (Not(IsComObjectCreated(hoEmail))) Begin
Send CreateComObject of hoEmail
End
Set ComSubject Of hoEmail To "This is a test"
Set ComBody Of hoEmail To "This is a test"
Set ComFrom Of hoEmail To "Chilkat Support <support@chilkatsoft.com>"
Get ComAddTo Of hoEmail "Chilkat Admin" "admin@chilkatsoft.com" To iSuccess
Get pvComObject of hoEmail to vEmail
Get ComSendEmail Of hoMailman vEmail To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoMailman To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComCloseSmtpConnection Of hoMailman To iSuccess
If (iSuccess <> True) Begin
Showln "Connection to SMTP server not closed cleanly."
End
Showln "Mail Sent!"
End_Procedure