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
Note that this should also work with other providers like Outlook.com 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 = "smtp.gmail.com:587" *** Important for Secure SSL/TLS connections loSmtp.lUseSsl = .T. loSmtp.cUsername = "yourEmail12@gmail.com" && or whatever uid is loSmtp.cPassword = "yourpassword" loSmtp.cSenderName= "wwIPstuff Samples" loSmtp.cSenderEmail = "firstname.lastname@example.org" loSmtp.cRecipient = ["Jimmy" <email@example.com>] *** 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 loSmtp.AddAttachment("c:\sailbig.jpg") loSmtp.AddAttachment("c:\sailbig_original.jpg","image/jpeg") llResult = loSmtp.Sendmail() IF llResult WAIT WINDOW "Mail sent..." nowait ELSE ? "Mail sending failed: " ? loSmtp.cErrorMsg ENDIF
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.
Comment or report problem with topic