Sending SSL Email with wwSmtp (GMail, Live, etc.)

The following example demonstrates sending an email with attachments via GMail.

In order to send TLS/SSL Emails you have to use the .NET mode of wwSmtp. To do this make sure you set loSmtp.nMailMode=0.

Note that this should also work with other providers like or any provider that requires SSL based SMTP connections.

DO wwSmtp 

LOCAL loSmtp as wwSmtp
loSmtp = CREATEOBJECT("wwSmtp")

loSmtp.nMailMode = 0  && .NET Mode required

*** Google SMTP server - requires login and SSL/TLS
loSmtp.cMailServer = ""

*** Important for Secure SSL/TLS connections
loSmtp.lUseSsl = .T.

loSmtp.cUsername = ""  && or whatever uid is
loSmtp.cPassword = "yourpassword"

loSmtp.cSenderName= "wwIPstuff Samples"
loSmtp.cSenderEmail = ""

loSmtp.cRecipient = ["Jimmy" <>]

*** Actual message properties
loSmtp.cSubject = "wwSMTP Test Message"
loSmtp.cMessage = "<b>HTML Test message from wwsmtp, to check out how this operation works.</b>"

*** If cMessage contains HTML set cContentType to text/html
loSmtp.cContentType = "text/html"

*** Optional To add attachments use Attachment and point at a full file path

llResult = loSmtp.Sendmail()
IF llResult
    WAIT WINDOW "Mail sent..." nowait
    ? "Mail sending failed: " 
    ? loSmtp.cErrorMsg

Gmail Configuration Needed

Note that if you have GMail business account (ie. you pay for Gmail) you'll need to enable Enforce Access to less secure Apps for all Users in order to allow external SMTP clients to send email through GMail. This might change for all Gmail accounts in the future. Update: Google now has made it just about impossible to use SMTP to send any longer via 'insecure apps' unless individual accounts are specifically configured with a nearly inaccessible property. Bottom line: Don't use Gmail for SMTP

© West Wind Technologies, 1996-2022 • Updated: 08/02/21
Comment or report problem with topic