It is currently Sun Jun 16, 2019 3:46 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Email code works in PB 5.61 but not 5.70 or 5.71
PostPosted: Mon Jun 03, 2019 7:16 am 
Offline
User
User

Joined: Wed May 07, 2008 4:57 am
Posts: 59
Location: Adelaide, South Australia
One of my users recently reported they are no longer able to send emails. After much investigation, it was demonstrated that the same code sends the email correctly if compiled using version 5.61 but not with 5.70. They are using smtp.office365.com as the email server. My own testing using a different smtp service sends emails correctly with 5.70 and 5.71. A few other users have also reported inability to send emails, too, but they use different smtp servers. Have not tried 5.62.

Dean Hodgson
Bookmark manager
Library System Analyst
Department for Education
South Australia
dean-hodgson@hotmail.com
dean.hodgson@sa.gov.au


Code:
;Email test program

InitNetwork()

Gosub SEND_EMAIL_TEST
End


;{ SENDEMAIL
SEND_EMAIL:
FLAG=0
A=CreateMail(0,EMAILSENDFROM$,EMAILSENDSUBJECT$) ;,#PB_Ascii)
If A
   SetMailBody(0,SENDBODY$)
   N=CountString(EMAILSENDTO$,";")+1
   For I=1 To N
      V$=Trim(StringField(EMAILSENDTO$,I,";"))
      AddMailRecipient(0,V$,#PB_Mail_To)
   Next
   EFLAG=1
   ;#PB_Mail_Asynchronous      ;1
   ;#PB_Mail_UseSSL            ;2
   ;#PB_Mail_Asynchronous | #PB_Mail_UseSSL   ;3
   If EMAILUSESSL
      EFLAG=3
   EndIf
   L=Len(EMAILLOGIN$)
   A=0
   If L
      A=SendMail(0,EMAILSMTPSERVER$,EMAILPORT,EFLAG,EMAILLOGIN$,EMAILPASSWORD$)
   Else
      A=SendMail(0,EMAILSMTPSERVER$,EMAILPORT,EFLAG)
   EndIf
   If A
      Progress=#PB_Mail_Error
      Repeat
         Progress=MailProgress(0)
         Delay(50)
         If ABORTBTN
            event=WindowEvent()
            E=0
            Select event
               Case #PB_Event_Gadget,#PB_Mail_Connected
                  E=EventGadget()
               Case #PB_Event_CloseWindow
                  E=ABORTBTN
            EndSelect
            If E=ABORTBTN
               Progress=#PB_Mail_Error
               FLAG=0
               Break
            EndIf
         EndIf
      Until Progress=#PB_Mail_Finished Or Progress=#PB_Mail_Error
      FLAG=Bool(Progress=#PB_Mail_Finished)
   EndIf
   FreeMail(0)
EndIf
Return

;}

;=====================================================================

SEND_EMAIL_TEST:

EMAILSMTPSERVER$="smtp.office365.com"   ; works in PB 5.61 but not 5.70     if smtp.iinet.net.au, works in 5.70, too
EMAILUSESSL=#True                                                ;false for iinet server
EMAILPORT=587                                                   ;25 for iinet server
EMAILLOGIN$="TheCorrectEmailAddress@rehoboth.wa.edu.au"               ;blank if iinet server used
EMAILPASSWORD$="TheCorrectPasswordHere"                           ;blank if iinet server used
EMAILSENDFROM$="alerts@rehoboth.wa.edu.au"                           ;dhodgson@iinet.net.au
EMAILSENDSUBJECT$="Email test"
EMAILSENDTO$="phurren@rehoboth.wa.edu.au"                           ;dhodgson@iinet.net.au or dean-hodgson@hotmail.com
SENDBODY$="Email test"+#CRLF$

FLAG=#False

If OpenWindow(1,#PB_Ignore,#PB_Ignore,320,140,"Send email",#PB_Window_TitleBar | #PB_Window_ScreenCentered)
   TextGadget(#PB_Any,X,Y,W,32,"Sending email...",#PB_Text_Center)
   ABORTBTN=ButtonGadget(#PB_Any,239,110,60,22,"Abort")
   StickyWindow(1,#True)
   SetActiveWindow(1)

   Gosub SEND_EMAIL

   CloseWindow(1)
EndIf

A$="Can't send the email"
If FLAG
   A$="Email sent"
EndIf

MessageRequester("Email",A$)

Return



Top
 Profile  
Reply with quote  
 Post subject: Re: Email code works in PB 5.61 but not 5.70 or 5.71
PostPosted: Mon Jun 03, 2019 10:27 am 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 18, 2019 8:17 am
Posts: 163
I'm not entirely convinced it's a PureBasic bug, but it's strange that it works in 5.61 but not 5.70.

Anyway, here's proof that it works with 5.70 for me with Gmail: https://i.imgur.com/NMZMpvj.png


Top
 Profile  
Reply with quote  
 Post subject: Re: Email code works in PB 5.61 but not 5.70 or 5.71
PostPosted: Tue Jun 04, 2019 6:45 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Aug 07, 2003 7:01 pm
Posts: 3097
Location: United Kingdom
I've experienced the same - it only seems to be an issue with office365 email - very odd.

_________________
http://www.SinisterSoft.com <- My Business website
http://www.ReportComplete.com and http://www.ReportPlus.co.uk <- School end of term reports system


Top
 Profile  
Reply with quote  
 Post subject: Re: Email code works in PB 5.61 but not 5.70 or 5.71
PostPosted: Mon Jun 10, 2019 8:09 am 
Offline
New User
New User

Joined: Wed Aug 23, 2017 11:16 am
Posts: 6
Confirmed cannot send to any email hosted in office365 for PB 5.70


Top
 Profile  
Reply with quote  
 Post subject: Re: Email code works in PB 5.61 but not 5.70 or 5.71
PostPosted: Tue Jun 11, 2019 5:39 am 
Offline
User
User

Joined: Wed May 07, 2008 4:57 am
Posts: 59
Location: Adelaide, South Australia
A bit of further testing demonstrated the problem does not exist with 5.62 but does with 5.70 and 5.71. Hopefully that will help narrow down where it lies. I have worked around the problem by making a DLL using 5.61 to send emails using office365.


Top
 Profile  
Reply with quote  
 Post subject: Re: Email code works in PB 5.61 but not 5.70 or 5.71
PostPosted: Tue Jun 11, 2019 5:48 am 
Offline
Addict
Addict
User avatar

Joined: Thu Aug 07, 2003 7:01 pm
Posts: 3097
Location: United Kingdom
I think the mail lib having better error reporting would help with issues like this - we would be able to pin point the error more accurately, I added it a while ago as a feature request.

viewtopic.php?f=3&t=72959

_________________
http://www.SinisterSoft.com <- My Business website
http://www.ReportComplete.com and http://www.ReportPlus.co.uk <- School end of term reports system


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye