SendMail()

Syntax

Result = SendMail(#Mail, Smtp$ [, Port [, Flags [, User$, Password$]]])
Description
Send the specified mail.

Parameters

#Mail The mail to send.
Smtp$ The address of the mail server to use for sending the mail.
Port (optional) The port of the mail server. The default is port 25.
Flags (optional) It can be a combination of the following values:
  #PB_Mail_Asynchronous: sends the mail in the background. MailProgress() can be used to follow the progress.
  #PB_Mail_UseSSL      : uses TLS/SSL to send the mail (the server needs to support this protocol).
User$, Password$ (optional) The user and password used for SMTP authentication, if the server requires it.

Return value

Returns nonzero if the mail was sent correctly and zero otherwise.

Example: Simple SMTP

  InitNetwork()

  ; Note: change the address and smtp to have a working example
  ;
  If CreateMail(0, "test@youraddress.com", "Hello")
    AddMailRecipient(0, "youraddress@youraddress.com", #PB_Mail_To)

    Debug SendMail(0, "smtp.yourfavoritesmtp.com")
  EndIf

Example: Using GMail (TLS)

  InitNetwork()

  ; Be sure to use the right login and right password
  ;
  Login$ = "yourlogin"
  If CreateMail(0, Login$ + "@gmail.com", "Hello")
    AddMailRecipient(0, "youraddress@youraddress.com", #PB_Mail_To)

    Debug SendMail(0, "smtp.gmail.com", 587, #PB_Mail_UseSSL, Login$, "password")
  EndIf

See Also

CreateMail(), MailProgress()

Supported OS

All

<- RemoveMailRecipient() - Mail Index - SetMailAttribute() ->