PureSMTP library

Overview

Send e-mails with Purebasic.

Features :
- authentication support [POP3 and SMTP AUTH]
- large files attachements

Error codes :
#PureSMTP_FileError = -1
#PureSMTP_NoConnection = -2
#PureSMTP_BadResponse = - 3
#PureSMTP_MemoryAllocationProblem = -4
#PureSMTP_AuthentificationFailed = -5
#PureSMTP_ServerTimeOut = -6

Functions

PureSMTP_SkipInitNetwork(SkipInit.l)

Skip InitNetwork() call.

By default, the library will call InitNetwork().
Note that InitNetwork() must only be called once. Use this function if you call InitNetwork() in your program to avoid the library calling it for the second time.

PureSMTP_SkipInitNetwork() must be called before any other function of this library.
PureSMTP_OpenPOP3ThenSMTPConnection(pop3server.s, POP3Port.l, POP3UserName.s, POP3UserPassword.s, SMTPServer.s, SMTPPort.l)

Open connection to POP3 server (authentication) and then to SMTP server.

Returns #PureSMTP_Ok if success (else is error code).

Note : if you call PureSMTP_OpenPOP3ThenSMTPConnection() without having closed the previous connection, PureSMTP will just keep using current connection.
PureSMTP_OpenSMTPConnection(SMTPServer.s, SMTPPort.l)

Open connection to SMTP server.

Returns #PureSMTP_Ok if success (else is error code).

Note : if you call PureSMTP_OpenSMTPConnection() without having closed the previous connection, PureSMTP will just keep using current connection.
PureSMTP_SendMail(MailTo.s, MailFrom.s, Subject.s, MsgBody.s, [Attachments.s, [UserName.s, [Password.s, [HeaderAddon.s]]]])

Send mail (and attached files).

Returns #PureSMTP_Ok if success (else is error code).

Sender :

Supports simple mail address ("name@domain.com") or real name + mail address ("Name <name@domain.com>")

Recipient(s) :

Supports simple mail address ("name@domain.com") or real name + mail address ("Name <name@domain.com>")

- 1 recipient :	MailTo.s = "User1@Server1.fr"
- X recipients :	MailTo.s = "User1@Server1.fr;User2@Server2.us;...;UserX@ServerX.ru"

To specify Carbon copy (CC:) or Blind Carbon Copy (BCC:), just add cc: or bcc: before the address :

- X recipients :	MailTo.s = "User1@Server1.fr;cc:User2@Server2.us;bcc:UserX@ServerX.ru"

Attachements :

- no file attached :	Attachements.s = ""
- 1 file attached :	Attachements.s = "Filename"
- X files attached :	Attachements.s = "Filename1;Filename2;...;FilenameX"

Authentication :

- SMTP AUTH : if the SMTP server requires authentication, use the optional parameters UserName and PassWord.
- POP3 AUTH : use the PureSMTP_OpenPOP3ThenSMTPConnection() function before PureSMTP_SendMail().

Optional header :

You can add a header text with the optional parameter HeaderAddon.
Example : HeaderAddon.s = "Date: 05 May 2005 12:00:00".
PureSMTP_CloseSMTPConnection()

Close the SMTP connection.
PureSMTP_GetLastServerMessage()

Get last server message.

Usefull after a #PureSMTP_BadResponse error.
PureSMTP_SetTimeOut(TimeOut.l)

Set timeout for PureSMTP_SendMail() in seconds.

Default value = 5.
PureSMTP_SetContentType(ContentType.s)

Set content type.

Default value = "text/plain; charset=iso-8859-1".
PureSMTP_SetXMailer(XMailer.s)

Set X-Mailer.

Default is "PureSMTP".
PureSMTP_SetBoundary(Boundary.s)

Set Boundary for multipart/mixed message.

Default is "PureSMTP_".
PureSMTP_AddHeader(Header.s, String.s)

Set additional header strings.
PureSMTP_ClearHeader()

Clears the additional the header strings.
PureSMTP_POP3Messages(pop3server.s, POP3Port.l, POP3UserName.s, POP3UserPassword.s)

Returns number of e-mails at POP3 server [>= 0 , else is error code].