The following script shows how to use the SendMail method:
email_host = "mailserver.mydomain.com"
email_from = "email@example.com"
email_to = "firstname.lastname@example.org"
email_text = "Subject: SendMail Test\r\n\r\n"
email_text += "Test email body."
status = smtp.SendMail(email_host, email_from,
Notice that in our example the message text contains a first line starting with the word “Subject” followed by the “:” character (semicolon) and by the subject text. This line is the header of our message. The body of the message must be separated from the header by two new lines (the combination of the characters CR, carriage return, and LF, line feed).
In the message header it is also possible to insert other fields that are specific to the SMTP header, such as “Cc:” (carbon copy), separated by a single new line character combination (CR+LF). The exact syntax is therefore: field_name + semicolon + value + CR + LF.
The SendMail method sends the message synchronously, which implies that script execution may block for several seconds waiting for an answer from the SMTP server. Additionally, no resend attempts take place if sending a message fails on the first attempt, and the email will not be sent to destination (unless the script is run again). See SendMailAsync method to avoid these problems.