PureSMTP library : mail & attachments (AUTH supported)
Moderator: gnozal
Re: PureSMTP library : mail & attachments (AUTH supported)
Can you developed a version in which html mail will be possible ?
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Re: PureSMTP library : mail & attachments (AUTH supported)
I do not know any SMTP command to handle the outbox.loulou wrote:Can you developed a version in which html mail will be possible ?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
- DoubleDutch
- Addict
- Posts: 3219
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
Re: PureSMTP library : mail & attachments (AUTH supported)
It may be handy to have a function to send RAW commands to the SMTP server and get the RAW reply (on the current PureSMTP connection)? Possible the same for the PurePop3 library too?
(I wish Fred would add this to his FTP and Mail libraries)
(I wish Fred would add this to his FTP and Mail libraries)
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Re: PureSMTP library : mail & attachments (AUTH supported)
Sending some user defined text is not a problem.DoubleDutch wrote:It may be handy to have a function to send RAW commands to the SMTP server and get the RAW reply (on the current PureSMTP connection)? Possible the same for the PurePop3 library too?
But how to handle the server answer ? It maybe a short text, megabytes of data, or an error message.
This is handled by a message loop in PureSMTP.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
- DoubleDutch
- Addict
- Posts: 3219
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
Re: PureSMTP library : mail & attachments (AUTH supported)
I see what you mean, maybe specify a timeout in the send command - all data captured in an expanding memory buffer until that time has passed since last data reply? It could default to 1/2 second? The memory address would be the return parameter?
eg:
This way other users can add commands that may be missing (they may only be on certain servers and not part of the official SMTP spec?) and submit them to you for 'offical' inclusion (if you like)?
eg:
Code: Select all
reply=PureSMTP_RawSend(command$[,timeout])
if reply
.
.
.
FreeMemory(reply)
endif
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Re: PureSMTP library : mail & attachments (AUTH supported)
I will try to think of something usable.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Re: PureSMTP library : mail & attachments (AUTH supported)
Is PureSMTP_SetContentType() meant to remember its setting after PureSMTP_CloseSMTPConnection() is called? Because once I set the content type to "text/html" and send an email, and close the connection, the next email sent is also "text/html" instead of the default of "text/plain". I would've thought the default would be used whenever PureSMTP_OpenSMTPConnection() is called?
Basically, I currently have to do this with my program:
Basically, I currently have to do this with my program:
Code: Select all
;monospaced is a global variable depending on how I want to send.
If PureSMTP_OpenSMTPConnection(...)=#PureSMTP_Ok
If monospaced=1
PureSMTP_SetContentType("text/plain; charset=iso-8859-1")
Else
PureSMTP_SetContentType("text/html; charset=iso-8859-1")
EndIf
result=PureSMTP_SendMail(...)
PureSMTP_CloseSMTPConnection()
EndIf
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Re: PureSMTP library : mail & attachments (AUTH supported)
Yes, like PureSMTP_SetXMailer() and PureSMTP_SetBoundary().C64 wrote:Is PureSMTP_SetContentType() meant to remember its setting after PureSMTP_CloseSMTPConnection() is called?
Set the value to "" to reset to default value.
I have updated the help file.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Re: PureSMTP library : mail & attachments (AUTH supported)
Thank you. Another question (for you or any lurkers): I can easily send image attachments with PureSMTP, but what about sending an HTML email with the image embedded? I know I'd have to compose the email body with HTML tags, but I'm unsure of how I'd get the image data in there. Base64 I assume, with boundaries? Am I close? Can someone post some theory so I can do the practice? Thanks again.
Re: PureSMTP library : mail & attachments (AUTH supported)
Found a bug (I think) in PureSMTP today, when trying to use PureSMTP_AddHeader(). Reproducible code follows (without my data). Example taken from the PureSMTP help file. Using PureBasic 4.51 and the latest PureSMTP library, on XP (32-bit). Turning the Purifier on gives a different address in the error message, rather than 0. Changing the addresses in MailTo and MailFrom doesn't fix the error.
Code: Select all
Line: 12 - Invalid memory access. (write error at address 0)
Code: Select all
MySMTPServer.s = "MySMTPServer"
MySMTPPort.l = 25
If PureSMTP_OpenSMTPConnection(MySMTPServer, MySMTPPort) = #PureSMTP_Ok
Debug PureSMTP_GetLastServerMessage()
MailTo.s = "whoever@you.want"
MailFrom.s = "root@127.0.0.1"
Subject.s = "Test"
MsgBody.s = "Testing PureSMTP"
Attachments.s = ""
;Username.s = "TEST"
;Password.s = "TEST"
PureSMTP_AddHeader("X-MSMail-Priority", "High")
; sending mail
Status.l = PureSMTP_SendMail(MailTo, MailFrom, Subject, MsgBody)
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
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Re: PureSMTP library : mail & attachments (AUTH supported)
Sorry, I can't reproduce the issue : the mail is sent with high priority as expected.C64 wrote:Found a bug (I think) in PureSMTP today, when trying to use PureSMTP_AddHeader(). Reproducible code follows (without my data). Example taken from the PureSMTP help file. Using PureBasic 4.51 and the latest PureSMTP library, on XP (32-bit). Turning the Purifier on gives a different address in the error message, rather than 0. Changing the addresses in MailTo and MailFrom doesn't fix the error.
No debugger error.
No purifier alert.
No crash.
PB4.51 / XP sp3 x86
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Re: PureSMTP library : mail & attachments (AUTH supported)
I noticed I also get the exact same crash with just one line in the IDE like this (compile/run it):
What does this do on your PC?
Code: Select all
PureSMTP_AddHeader("X-MSMail-Priority", "High")
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Re: PureSMTP library : mail & attachments (AUTH supported)
Nothing.C64 wrote:I noticed I also get the exact same crash with just one line in the IDE like this (compile/run it):What does this do on your PC?Code: Select all
PureSMTP_AddHeader("X-MSMail-Priority", "High")
Note : this function just adds an element to a linked list in the library.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Re: PureSMTP library : mail & attachments (AUTH supported)
With the Purifier enabled, the single line compiles and runs fine. Disabled, it crashes. Just musing out loud.
[Update] Just noticed that if I enable "Create Threadsafe Executable", the single lines causes this:
[Update] Just noticed that if I enable "Create Threadsafe Executable", the single lines causes this:
Code: Select all
---------------------------
PureBasic - Linker error
---------------------------
POLINK: error: Unresolved external symbol '_PB_StringBasePosition'.
POLINK: fatal error: 1 unresolved external(s).
---------------------------
OK
---------------------------
- DoubleDutch
- Addict
- Posts: 3219
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
Re: PureSMTP library : mail & attachments (AUTH supported)
You should do a reinstall of purebasic and the extra libs - it works fine on mine.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
https://reportcomplete.com <- School end of term reports system