CUrlSMTP – documentation

The following is the documentation for my SMTP replacement library based on CUrl and GMIME, for details, please see the corresponding Blog post.

CUrlSmtp_AddHeader

dummy:=CUrlSmtp_AddHeader( SmtpObject;headerName;headerText{;handleOption})

adds a header to the message object in the smtp object options determine how to handle existing content

Parameters
$1ObjectrequiredThe SMTP Object
$2Textrequiredthe header key
$3Textrequiredthe header value
$4Longintoptionalhow to handle existing content
0 = just add the header (default)
1 = replace all existing with this one
2 = delete all corresponding headers
$0Longintalways 0

CUrlSmtp_Attachment

Error:=CUrlSmtp_Attachment(SmtpObject;filename;encode_type{;handleOption{;attachmentID}})

adds an attachment, replaces attachments or removes them

Parameters
$1ObjectrequiredThe SMTP Object
$2Textrequiredthe file path or file name, keep empty if you want
$3Longintrequiredwas used for encoding options. obsolete, we do all in base64
$4Longintoptionalhow to handle existing content
0 = Add (default)
1 = Replace
2 = Remove
$5Textoptionalthe id of the attachment, only used if the attachment is inline of an html mail
$0LongintError code

CUrlSmtp_Auth

dummy:=CUrlSmtp_Auth(SmtpObject;username;password{;AuthOption})

prepares the authentication by setting username and password

Parameters
$1ObjectrequiredThe SMTP Object
$2Textrequiredthe username
$3Textrequiredthe password
$4Longintoptionalwas used for auth options, obsolete as cUrl handles all that
$0Longintalways 0

CUrlSmtp_Bcc

dummy:=CUrlSmtp_Bcc(SmtpObject;Address{;Handling})

adds a new “bcc” address to the smtp object

Parameters
$1ObjectrequiredThe SMTP Object
$2Textrequiredemail address
$3longintoptionalhandling option
0: add (default)
1: replace
2: delete
$0LongintError Code

CUrlSmtp_Body

dummy:=CUrlSmtp_Body(SmtpObject;body{;handleOption})

sets the body of the message, handling options may apply

Parameters
$1ObjectrequiredThe SMTP Object
$2Textrequiredthe email body
$3Longintoptionalhow to handle content
0 = Replace if msgBody not empty (default)
1 = Delete
2 = Append
4 = HTML text - cannot be combined with the other options!
$0LongintAlways 0

CUrlSmtp_Cc

dummy:=CUrlSmtp_Cc(SmtpObject;Address{;Handling})

adds a new “cc” address to the smtp object

Parameters
$1ObjectrequiredThe SMTP Object
$2Textrequiredemail address
$3Longintoptionalhandling option
0: add (default)
1: replace
2: delete
$0LongintError Code

CUrlSmtp_CheckSendable

Error:=CUrlSmtp_CheckSendable(SmtpObject)

checks if the minimum requirements for sending a mail are met

Parameters
$1ObjectrequiredThe SMTP Object
$0BooleanTRUE if can be sent

CUrlSmtp_Clear

dummy:=CUrlSmtp_Clear(SmtpObject)

just a call to a clear variable

Parameters
$1ObjectrequiredThe SMTP Object
$0LongintAlways 0

CUrlSmtp_Date

CUrlSmtp_Date(SmtpObject;Date;Time{;timeZone;Offset{;handling}})

sets the message date and time, always in GMT all the fancy time zone and offset options are totally ignored, can’t see the point of these…

Parameters
$1ObjectrequiredThe SMTP Object
$2daterequiredthe message date
$3timerequiredthe message time
$4longintoptionaltimezone - ignored
$5longintoptionaloffset - ignored
$6longintoptionalhow to handle existing content
0 = add or replace
1 = Delete
$0LongintError code

CUrlSmtp_Debug

CUrlSmtp_Debug(SmtpObject;Debug{;ShowDebugMessage{;ShowHeaderMessage}})

sets the desired debug options
the second and third option only take effect if the first one is set

Parameters
$1ObjectrequiredThe SMTP Object
$2Booleanrequireddebug communication
$3Booleanoptionalshow the communication in a message box
$4Booleanoptionalshow the header in a message box

CUrlSmtp_From

Dummy:=CUrlSmtp_From(SmtpObject;Address{;Handling})

adds the FROM address to the smtp object

Parameters
$1ObjectrequiredThe SMTP Object
$2Textrequiredemail address
$3Longintoptionalhandling option
0: add (default)
1: replace
2: delete
$0LongintError Code

CUrlSmtp_GetDebugInfo

info:=CUrlSmtp_GetDebugInfo(SmtpObject;what)

returns the requested error info from the SMTP object

Parameters
$1ObjectrequiredThe SMTP Object
$2TextrequiredThe error info desired. Valid options are:
result - the result number of the cUrl call
header - the header of the call
debug - the full transcript of the cUrl call
curlinfo - the info after the call (json)
lasterror - the last error
errorstack - the list of all errors encountered
$0TextThe requested information

CUrlSmtp_Host

Error:=CUrlSmtp_Host(SmtpObject;Host{;Port})

sets the host for the email

Parameters
$1ObjectrequiredThe SMTP Object
$2Textrequiredthe host address, can contain a port number: host:port
$3Longintoptionala port number if required
$0LongintError code

CUrlSmtp_MakeAddress

Address:=CUrlSmtp_MakeAddress(Address{;Name})

creates an address object from the email address and optional name passed
will parse a fully encoded email address : fristname lastname <email@addr.ess>

Parameters
$1Textrequiredthe address, either only mail or fully encoded : fristname lastname
$2Textrequiredthe name if not in address, careful, never pass both!
$0ObjectThe Address object to add to the recipient array

CUrlSmtp_New

SmtpObject:=CUrlSmtp_New

creates and initialises a fresh Smtp object

Parameters
$1Pointerrequiredpointer to an empty c_object
$0LongintAlways 0

CUrlSmtp_QuickSend

Error:=CUrlSmtp_QuickSend( hostName ; msgFrom ; msgTo ; subject ; message {; sessionParam}{; port}{; userName ; password} )

will send a mail with the parameters provided

Parameters
$1TextrequiredHost name or IP address
$2TextrequiredFrom : MailAddress or AddressList
$3TextrequiredTo : MailAddress or AddressList
$4TextrequiredSubject of message
$5TextrequiredMessage
$6Longintoptionalsession Parameter - ignored
$7LongintoptionalNumber of port to use
$8TextoptionalUser name for authentication
$9TextoptionalPassword for authentication
$0LongintError Code

CUrlSmtp_References

Error:=CUrlSmtp_References(SmtpObject;Reference{;handling})

sets the reference header for a message

Parameters
$1ObjectrequiredThe SMTP Object
$2Textrequiredthe reference
$3Longintrequiredhow to handle existing content
0 = Add or Replace if value not empty (default)
1 = Add or Replace, delete if value empty
2 = Delete
$0LongintError code

CUrlSmtp_Send

Error:=CUrlSmtp_Send(SmtpObject{;SSLOption})

sends the mail and returns either an error or 0
additional information can be read from the SmtpObject after sending

Parameters
$1ObjectrequiredThe SMTP Object
$2LongintrequiredSSL Option - only 2 (no SSL) is actually respected as cUrl handles all the other stuff
0 or omitted=Do not use SSL but switchover allowed
1=Use SSL
2=Never use SSL(switchover
$0LongintError code

CUrlSmtp_Source

Mime:=CUrlSmtp_Source(SmtpObject)

parses the SmtpObject and creates a blob with the MIME message, complete with headers and all included files

Parameters
$1ObjectrequiredThe SMTP Object
$0BlobA Blob with the full Email Source in UTF-8

CUrlSmtp_Subject

dummy:=CUrlSmtp_Subject(SmtpObject;Subject{;option})

sets or modifies the subject

Parameters
$1ObjectrequiredThe SMTP Object
$2Textrequiredthe subject
$3Longintrequiredhow to handle existing content
0 = Replace if subject not empty (default)
1 = Replace
2 = Delete
$0LongintError code

CUrlSmtp_To

dummy:=CUrlSmtp_To(SmtpObject;Address{;Handling})

adds or modifies a “to” address to the smtp object

Parameters
$1ObjectrequiredThe SMTP Object
$2Textrequiredthe address, either only mail or fully encoded : fristname lastname
$3Longintoptionalhandling option
0: add (default)
1: replace
2: delete
$0LongintError Code