Sample code for 30+ languages & platforms
AutoIt

Send an Email via SMTP

See more SMTP Examples

Demonstrates the Chilkat MailMan.SendEmail method, which sends a single Email object through the configured SMTP server. This example configures the SMTP connection, builds a message, and sends it.

Background: SMTP (Simple Mail Transfer Protocol) is the protocol for sending mail. The typical flow is: connect to the server, authenticate, then hand over the message with MAIL FROM, RCPT TO, and DATA. SendEmail wraps all of that: you build an Email with subject, recipients, and body, and Chilkat renders it to MIME and delivers it. Modern submission commonly uses implicit TLS on port 465 (SmtpSsl = true).

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

;  Demonstrates the MailMan.SendEmail method, which sends a single Email object through the
;  configured SMTP server.

$oMailman = ObjCreate("Chilkat.MailMan")

;  Configure the SMTP server connection.
$oMailman.SmtpHost = "smtp.example.com"
$oMailman.SmtpPort = 465
$oMailman.SmtpSsl = True
$oMailman.SmtpUsername = "user@example.com"
$oMailman.SmtpPassword = "myPassword"

;  Build the email to send.
$oEmail = ObjCreate("Chilkat.Email")
$oEmail.Subject = "Test email from Chilkat"
$oEmail.From = "alice@example.com"
$oEmail.AddTo("Bob","bob@example.com")
$oEmail.Body = "Hello, this is a test message."

;  Send the email.

$bSuccess = $oMailman.SendEmail($oEmail)
If ($bSuccess = False) Then
    ConsoleWrite($oMailman.LastErrorText & @CRLF)
    Exit
EndIf

ConsoleWrite("Email sent." & @CRLF)

;  Note: Explicitly connecting/authenticating is optional.  Chilkat MailMan automatically
;  connects and authenticates -- using the property settings above -- whenever a server
;  operation requires it.  Calling the explicit connect/authenticate methods can still be
;  helpful to determine whether a failure occurs while connecting or while authenticating.