Page 9 of 25

Posted: Sat Jan 27, 2007 3:21 pm
by Flype
Frontier wrote:I've tried PureSMTP_SetContentType("multipart/mixed; charset=iso-8859-7")
maybe this way :

PureSMTP_SetContentType("text/plain; charset=iso-8859-7")

Posted: Sat Jan 27, 2007 4:10 pm
by Frontier
Flype wrote:
Frontier wrote:I've tried PureSMTP_SetContentType("multipart/mixed; charset=iso-8859-7")
maybe this way :

PureSMTP_SetContentType("text/plain; charset=iso-8859-7")
It worked :D
I thought I could not use the "text/plain" content type class, because my message was in Unicode Greek; seems the SMTP server was smart enough not to destroy the message.

Thank you very much for your help.

Posted: Sat Jan 27, 2007 8:52 pm
by akj
I have never been able to get PureSMTP_SetXMailer() working for PureSMTP versions 5.20 to 5.60. It always gives an error [reported by the PB debugger] of "Invalid memory access".

The code line I am trying to get working (after establishing a valid SMTP connection) is:

Code: Select all

PureSMTP_SetXMailer("LockOff")
If it is relevant, I am using Windows ME and PB 4.02 .

Gnozal, could you please check for the possibility of a bug in your coding of PureSMTP_SetXMailer() ?

Posted: Sat Jan 27, 2007 9:18 pm
by Flype
@frontier
Cool. PureSMTP_SetContentType("text/plain; charset=iso-8859-1") for french language works for me so i guessed it should also works for your language :wink:

@akj
PureSMTP_SetXMailer("myprogram") works for me on XP SP2.
So it should be a bug related to Windows ME.

Posted: Sat Jan 27, 2007 11:07 pm
by Frontier
Indeed, PureSMTP_SetXMailer works for me also on both Windows Server 2003 x64 and Windows XP Pro SP2 (Tablet PC edition).

Posted: Sun Jan 28, 2007 9:39 pm
by akj
When I do a run-time trap of the error message generated by PureSMTP_SetXMailer() on my Windows ME computer I get:

Error code = $C0000005
Message = Access Violation of a Virtual Address Read from address $FFFFFFFF

Does anyone know a cure for the above error?

Unfortunately I also get the same error with PureSMTP_SetContentType() thus rendering PureSMTP virtually useless to me as I wish to send HTML emails.

Is it possible to get hold of a version of the PureSMTP library where content type text/html is the default rather than text/plain ?

Posted: Mon Jan 29, 2007 9:33 am
by gnozal
All I can say is PureSMTP_SetXMailer() also works with Windows NT4. Could not test it with Win98SE.

I can't see why it shouldn't work, it's a one line code !

Code: Select all

Global ..., PureSMTP_XMailer.s, ...

ProcedureDLL PureSMTP_Init()
  ...
  PureSMTP_XMailer = "PureSMTP"
  ...
EndProcedure

ProcedureDLL PureSMTP_SetXMailer(XMailer.s) ; Set X-Mailer [Default is "PureSMTP"]
  PureSMTP_XMailer = XMailer
EndProcedure

Posted: Mon Jan 29, 2007 11:36 am
by DoubleDutch
akj: Have you tried completely powering off your machine then turning it back on and trying again.

I have had some really strange problems with the latest version of PB, they are fixed once I turn off and restart the machine. I haven't been able to isolate what is the cause at present. Next time it happens I am going to build an assembly 'source' version, restart and then compare the two.

Posted: Mon Jan 29, 2007 6:58 pm
by DoubleDutch
There seems to be a problem with PureSMTP and running a network server...

With this code, the client can connect to the server - but no data can be transfered. Comment out the PureSMTP code and it works fine.

Code: Select all

If InitNetwork() = 0
  MessageRequester("Error", "Can't initialize the network !", 0)
  End
EndIf

Port = 6832
Buffer = AllocateMemory(1000)

If CreateNetworkServer(0, Port)
  MessageRequester("PureBasic - Server", "Server created (Port "+Str(Port)+").", 0)
 
; ******

MySMTPServer.s = "MySMTPServer"
MySMTPPort.l = 25
If PureSMTP_OpenSMTPConnection(MySMTPServer, MySMTPPort) = #PureSMTP_Ok
  Debug PureSMTP_GetLastServerMessage()
  MailTo.s = "MyName@MyServer"
  MailFrom.s = "PureSMTP@testing"
  Subject.s = "Test (with login authentication)"
  MsgBody.s = "Testing PureSMTP"
  Attachments.s = ""
  UserName.s = "TEST"
  Password.s = "TEST"
  ; sending mail
  Status.l = PureSMTP_SendMail(MailTo, MailFrom, Subject, MsgBody, Attachments, UserName, Password)
  If Status = #PureSMTP_Ok
    Debug "Message : sent"
    Debug "Status = " + Str(Status)
  Else
    Debug "Message : something went wrong !"
    Debug "Status = " + Str(Status)
    Debug PureSMTP_GetLastServerMessage()
  EndIf
  PureSMTP_CloseSMTPConnection()
Else
  Debug "OpenSMTPConnection failed"
  Debug PureSMTP_GetLastServerMessage()
EndIf

; ****** 
 
   ConnectionID = OpenNetworkConnection("127.0.0.1", Port)
   If ConnectionID
     MessageRequester("PureBasic - Client", "Client connected to server...", 0)
     SendNetworkString(ConnectionID, "An hello from a client !!! :-)")
     MessageRequester("PureBasic - Client", "A string has been sent to the server, please check it before quit...", 0)
     CloseNetworkConnection(ConnectionID)
   Else
     MessageRequester("PureBasic - Client", "Can't find the server (Is it launched ?).", 0)
   EndIf
 
  Repeat
    SEvent = NetworkServerEvent()
    If SEvent
      ClientID = EventClient()
      Select SEvent
        Case 1
          MessageRequester("PureBasic - Server", "A new client has connected !", 0)
 
        Case 2
          MessageRequester("PureBasic - Server", "Client "+Str(ClientID)+" has send a packet !", 0)
          ReceiveNetworkData(ClientID, Buffer, 1000)
          MessageRequester("Info", "String: "+PeekS(Buffer), 0)
 
        Case 4
          MessageRequester("PureBasic - Server", "Client "+Str(ClientID)+" has closed the connexion...", 0)
          Quit = 1
   
      EndSelect
    EndIf
   
  Until Quit = 1
 
  MessageRequester("PureBasic - Server", "Click to quit the server.", 0)
  CloseNetworkServer(0)
Else
  MessageRequester("Error", "Can't create the server (port in use ?).", 0)
EndIf
End

Posted: Mon Jan 29, 2007 8:16 pm
by thefool
Confirmed!

Posted: Tue Jan 30, 2007 9:31 am
by gnozal
DoubleDutch wrote:There seems to be a problem with PureSMTP and running a network server...

With this code, the client can connect to the server - but no data can be transfered. Comment out the PureSMTP code and it works fine.
You are right.

I have found the problem.
The library uses InitNetwork() before calling OpenNetworkConnection().
So with your code, InitNetwork() is called twice. If I remove InitNetwork() in PureSMTP, it works fine.

How to be sure that InitNetwork() has been called if I remove it from the library ?

EDIT : I could also move InitNetwork() to PureSMTP_Init(), so it is only called one and in your code just don't call InitNetwork() when you use the library.

Posted: Tue Jan 30, 2007 10:40 am
by DoubleDutch
I think that this is something that Fred should sort out.

Maybe there should be an internal 'virgin' flag associated with the Init... commands so they will be bypassed if they are called twice.

You fix the problem temporarily you could add a flag that could be set with an advanced command.

eg:

Code: Select all

PureSMTP_SkipInitNetwork(#True)  ; defaults to false on library init
also, don't forget...

Code: Select all

PurePOP3_SkipInitNetwork(#True) ; defaults to false on library init


:)

I've posted it to suggestions:

http://www.purebasic.fr/english/viewtop ... 161#180161

Posted: Tue Jan 30, 2007 10:44 am
by gnozal
DoubleDutch wrote:I think that this is something that Fred should sort out.
What do you think of this : I could also move InitNetwork() to PureSMTP_Init(), so it is only called once and in your code just don't call InitNetwork() when you use the library. So it works.

Hum, bad idea ...It would not work if you use PureSMTP and PurePOP3 together ...
I will use your flag idea.

Posted: Tue Jan 30, 2007 11:08 am
by akj
DoubleDutch:

Following your suggestion, I have tried running my program (as an .EXE file) immediately after cold-booting my PC but I still get the same error message of "Access Violation of a Virtual Address Read from address $FFFFFFFF".

I am now resigned to not being able to fully use Gnozal's package for my particular application requirements. Does anyone know of any other PureBasic SMTP package that will allow me to easily send emails in HTML format?

Posted: Tue Jan 30, 2007 11:27 am
by DoubleDutch
That should work.

When does PureSMTP_Init() get called?

Is it called with the first Pure_SMTP command, or when the program that includes a Pure_SMTP itself is initialised?

[EDIT]

This doesn't matter if your using the flag idea... :)