SendMail()
Syntax
Result = SendMail(#Mail, Smtp$ [, Port [, Flags [, User$, Password$]]])Description
Send the specified mail.
Parameters
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). #PB_Mail_UseSMTPS : uses SMTPS to send the mail (the server needs to support this protocol). #PB_Mail_Debug : to print in the console debug information.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
; 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 Hotmail (TLS)
Login$ = "you@hotmail.com"
Password$ = "password"
Receiver$ = "test@gmail.com"
If CreateMail(0, Login$, "Hello")
AddMailRecipient(0, Receiver$, #PB_Mail_To)
Debug SendMail(0, "smtp-mail.outlook.com", 587, #PB_Mail_UseSSL, Login$, Password$)
EndIf
Example: Using GMail (TLS+SMTPS)
; Be sure to use the right login and right password
;
Login$ = "yourlogin"
Password$ = "password"
Receiver$ = "test@gmail.com"
If CreateMail(0, Login$ + "@gmail.com", "Hello")
AddMailRecipient(0, Receiver$, #PB_Mail_To)
Debug SendMail(0, "smtp.gmail.com", 465, #PB_Mail_UseSSL | #PB_Mail_UseSMTPS, Login$, Password$)
EndIf
See Also
CreateMail(), MailProgress()
Supported OS
All