PureSMTP library : mail & attachments (AUTH supported)

All PureFORM, JaPBe, Libs and useful code maintained by gnozal

Moderator: gnozal

User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post 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")
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
User avatar
Frontier
User
User
Posts: 74
Joined: Thu Dec 22, 2005 2:43 pm
Location: Chios, Greece
Contact:

Post 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.
akj
Enthusiast
Enthusiast
Posts: 668
Joined: Mon Jun 09, 2003 10:08 pm
Location: Nottingham

Post 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() ?
Anthony Jordan
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post 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.
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
User avatar
Frontier
User
User
Posts: 74
Joined: Thu Dec 22, 2005 2:43 pm
Location: Chios, Greece
Contact:

Post by Frontier »

Indeed, PureSMTP_SetXMailer works for me also on both Windows Server 2003 x64 and Windows XP Pro SP2 (Tablet PC edition).
akj
Enthusiast
Enthusiast
Posts: 668
Joined: Mon Jun 09, 2003 10:08 pm
Location: Nottingham

Post 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 ?
Anthony Jordan
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post 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
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post 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.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post 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
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

Confirmed!
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post 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.
Last edited by gnozal on Tue Jan 30, 2007 10:40 am, edited 1 time in total.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post 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
Last edited by DoubleDutch on Tue Jan 30, 2007 10:45 am, edited 1 time in total.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post 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.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
akj
Enthusiast
Enthusiast
Posts: 668
Joined: Mon Jun 09, 2003 10:08 pm
Location: Nottingham

Post 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?
Anthony Jordan
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post 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... :)
Last edited by DoubleDutch on Tue Jan 30, 2007 11:33 am, edited 1 time in total.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Post Reply