Sending to SMTP server

Just starting out? Need help? Post your questions and find answers here.
bhicketts
New User
New User
Posts: 1
Joined: Thu Oct 12, 2017 10:00 pm

Sending to SMTP server

Post by bhicketts »

Hi, I have purebasic 5.60 x86 running on windows 7 32-bit. When I run the code below it functions perfectly. I tried the same code on my laptop and it fails . Always gives error 0. The laptop is running windows 10 64-bit. I've tried with PB 5.6 x86 and 64 but it's still the same. Any ideas would be appreciated.

Code: Select all


InitNetwork()

OpenConsole()

Define CRLF.s=Chr(13)+Chr(10)
Define result.i
Define mailNumber.i 
Define mailHost.s     = "smtp.gmail.com"
Define userName.s     = "bhicketts@gmail.com"
Define mailFrom.s 
Define password.s     = "bjh582946"
Define mailTo.s       = "bhicketts@gmail.com"
Define subject.s      = "64 bit email Test using TLS Encryption"
Define emailBody.s    
Define mailPort.i     = 587

emailbody="Dear Sir/Madam, this email is from PureBasic Version 5.40 TLS Encryption."+CRLF
PrintN("SendEmail() > About to create mail!")

mailNumber = CreateMail(#PB_Any, userName, subject)
Delay(300)
If mailNumber > 0
    AddMailRecipient(mailNumber, mailTo, #PB_Mail_To)
    SetMailBody(mailNumber, emailBody)
    result = SendMail(mailNumber, mailHost, mailPort, #PB_Mail_UseSSL, userName, password)
    FreeMail(mailNumber)
    PrintN("SendEmail() > completed, return value: " + Str(result))
Else
    PrintN("SendEmail() > error creating mail process")
EndIf

Input()

CloseConsole()