Upopmail and gmail

Author: i.sharp@pcisystems.co.uk (Iain Sharp)

One of our users is moving 'to the cloud' for their backoffice (except for our system),  so they have no exchange or other mail server.We are being asked to send mail via smtp.gmail.com.  To get the mails to send correctly from sql server, I have set up the server as smtp.gmail.com port 587, basic authentication, with a user name and password, and then am required to tick 'This server requires a secure connection (SSL)' before it will actually send.  In Uniface for Upopmail I have set the server name to smtp.gmail.com+587, and have tried all three authentication methods provided. The only one which says it can do encryption is the UAuthSSPISMTP driver, but this (and both of the others) is returning a -7 in the LogonSMTP operation, (server does not support security driver functionality).  Anyone know the magic settings to connect upopmail to gmail? 

8 Comments

  1. Hi Iain, When using the UPOPMAIL component you can access a mail server that is using SSL with a SSL proxy (e.g. stunnel). At this moment UPOPMAIL unfortunately does not support SSL. Using stunnel should be simple: you install it, add the following settings to the stunnel.conf config file, and then start the proxy:

    ; stunnel.conf [gmail] client = yes accept = 127.0.0.1:465 connect = smtp.gmail.com:465 And from Uniface, instead of accessing the gmail mail server directly, you use the local stunnel proxy. E.g.

    UPopMail->LogonSMTP ("127.0.0.1+465","","") And it should work when using the Uniface AUTH LOGIN security driver (that provides SMTP authentication using basic authentication). Hope this helps. Daniel


    Author: diseli (daniel.iseli@uniface.com)
  2. Hello,   I know this thread is a bit old now but I'm trying to do exactly the same thing - use UPOPMAIL to deliver emails via gmail. I have followed the info regarding stunnel etc but I can't get it to work. Could you give me some more info? Maybe even an extract of the uniface code that establishes the connection and the login etc. as well as exactly how stunnel.conf should look.   Thanks Colin Douglass


    Author: Colin (cdouglass@siriussoftware.com.au)
  3. Hi Colin, There isn't really much more to it than what Daniel wrote. What exactly is the error you are getting ? Cheers Chris


    Author: Chris Breemer (chris.breemer@uniface.com)
  4. thanks for replying Chris.   Here is my Uniface code variables handle gmailhandle endvariables askmess "this will send a test email. OK to continue","Yes,No" if ($status = 2) exit (0) endif $email_to$ = "cdouglass@siriussoftware.com.au" $email_from$ = "testemail@uniface9603.com.au" $email_server$ = "smtp.gmail.com" $email_subject$ = "Test Email from uniface9603" ; Create an instance handle of the UPOPMAIL API component newinstance "UPOPMAIL", gmailhandle ; set security gmailhandle->SetSecurity("SMTP=UAuthLoginSMTP·;USE=OPT","gmailusername·;password=gmailpassword") if ($status < 0) askmess "error with SetSecurity - status = %%$status%%%","OK" exit (0) endif ; Logon to the SMTP server ;gmailhandle->LogonSMTP($email_server$, "", "") gmailhandle->LogonSMTP("127.0.0.1+465", "", "") if ($status < 0) askmess "error with loginsmtp - status = %%$status%%%","OK" exit (0) endif gmailhandle->SetFrom($email_from$) if ($status < 0) askmess "error with setfrom - status = %%$status%%%","OK" exit (0) endif gmailhandle->SetToList($email_to$) if ($status < 0) askmess "error with settolist - status = %%$status%%%","OK" exit (0) endif gmailhandle->SetSubject("%%$email_subject$%%% - using a handle") if ($status < 0) askmess "error with setsubject - status = %%$status%%%","OK" exit (0) endif ; Specify the message body ;gmailhandle->SetMessage(TEXT,"") ; plain text body ;gmailhandle->SetMessage(HTML, "MIMEType=text/html") ; HTML body gmailhandle->SetMessage("This is the main body of the new email - text only%%^ %%^ ","") ; plain text body if ($status < 0) askmess "error with setmessage - status = %%$status%%%","OK" exit (0) endif ; Add an attachment ;gmailhandle->AddAttachmentFromFile(ATTACHMENT.MESSAGE.DUMMY, "") ; Send the message gmailhandle->Send("IgnoreRcptError=True") if ($status < 0) askmess "error with send - status = %%$status%%%","OK" exit (0) endif ; Clear the mail message structure from memory gmailhandle->ClearMail() if ($status < 0) askmess "error with clearmail - status = %%$status%%%","OK" exit (0) endif ; Log off the SMTP server gmailhandle->LogoffSMTP() if ($status < 0) askmess "error with logoffsmtp - status = %%$status%%%","OK" exit (0) endif return (0) ;;;;;;;;;;;;;;;; here is the snippet from stunnel.conf just as Daniel described [gmail] client = yes accept = 127.0.0.1:465 connect = smtp.gmail.com:465 There are also other labels in stunnel.conf like [gmail-smtp] and [gmail-pop3]. I just left them there. ;;;;;;;;;;;;;;;;;;   extract from usys.asn [USER_3GL] irtl.dll upostmsg.dll useqreadv8.dll c:\windows\system32\shell32.dll uauthlogin.dll ;;;;;;;;;;;;;;;;;;; I have also installed the Microsoft Loopback Device When I run it I get an error of $status -9 which debug shows me is a socket error: Object Lookup: C:\frms\uniface9\dol\udesc.urr Object Lookup: C:\Program Files (x86)\Compuware\Uniface 9.6.01\common\usys\usys.urr Object size=0014397 sig/upopmail.sig Loaded 'upop' from C:\Program Files (x86)\Compuware\Uniface 9.6.01\common\bin\upop.dll, version: 9.6.06 X603 UPOPMAIL: Version 9.6.06 X603 20150218.142355 (_execute) EXEC:11 GMAILHANDLE->SetSecurity("SMTP=UAuthLoginSMTPUSE=OPT","gmailusernamepassword= Loaded 'uauthlogin.dll' from C:\Program Files (x86)\Compuware\Uniface 9.6.01\common\bin\uauthlogin.dll, version: 9.6.06 X603 UPOPMAIL: <D0> SETSECURITY: Driver SMTP=UAuthLoginSMTPUSE=OPT: USEC_DRVINFO=USEC_SUCCESS: Initialised (_execute) EXEC:12 if ($status < 0) (_execute) EXEC:15 endif (_execute) EXEC:16 GMAILHANDLE->LogonSMTP("127.0.0.1+465","","") UPOPMAIL: <F1> LOGONSMTP: Using port 465 in stead of default port UPOPMAIL: <F1> LOGONSMTP: Opening connection with SMTP server: 127.0.0.1 and port: 465 UPOPMAIL: <E1> SOCKOPEN: Socket connect error. (_execute) EXEC:17 if ($status < 0) (_execute) EXEC:18 askmess "error with loginsmtp - status = %%$status", "OK" (_execute) EXEC:19 exit 0 ;;;;;;;;;;;;;;;;;; Any help you can give would be greatly appreciated, I'm at the the end of my abilities I'm afraid. I'm using Windows Server 2014 and Uniface 9.6.06 Thanks, Col.


    Author: Colin (cdouglass@siriussoftware.com.au)
  5. I've solved it. The problem was actually with gmail not allowing logins from older less secure apps - which I suppose UPOPMAIL is. Once I relaxed that rule it all worked. The suggestion from stunnel to install a loopback driver was also B/S. It not only interfered with the connection to gmail, it also screwed up connecting to Uniface services. This may have been because of my lack of networking knowledge but removing it worked so that's how it will stay. So, thanks to all.   Col.


    Author: Colin (cdouglass@siriussoftware.com.au)
  6. Hi Colin, I only saw your posting today, sorry. Great that you have already cracked it ! I did not know about gmail not liking UPOPMAIL as a client - a useful thing to keep in mind ! How and where exactly did you relax that rule ? Also I never installed/used a loopback device in order to use stunnel. Guess I had not read the documentation THAT well ;-)   Cheers, Chris


    Author: Chris Breemer (chris.breemer@uniface.com)
  7. Hi Chris,   to relax the less secure apps rule, login to your gmail account and then go here https://www.google.com/settings/security/lesssecureapps   Col.


    Author: Colin (cdouglass@siriussoftware.com.au)
  8. Thank you Colin ! Very useful info, I have filed it for future reference.   Cheers Chris


    Author: Chris Breemer (chris.breemer@uniface.com)