SMTP/POP3 Email Engine
Reference Library
(SEE_REF)
Version 3.2
January 10, 2000
This software is provided as-is.
There are no warranties, expressed or implied.
Copyright (C) 2000
All rights reserved
MarshallSoft Computing, Inc.
Post Office Box 4543
Huntsville AL 35815 USA
Voice : 256-881-4630
FAX : 256-880-0925
email : info@marshallsoft.com
web : www.marshallsoft.com
MarshallSoft is a member of the Association of Shareware Professionals
MARSHALLSOFT is a registered trademark of MarshallSoft Computing.
1 Introduction
1.1 General Remarks2 SEE Functions
1.2 Documentation Set
1.3 Declaration Files
2.1 seeAttach
2.2 seeCommand
2.3 seeClose
2.4 seeDebug
2.5 seeDecodeBuffer
2.6 seeDeleteEmail
2.7 seeDriver
2.8 seeEncodeBuffer
2.9 seeErrorText
2.10 seeExtractLine
2.11 seeExtractText
2.12 seeGetEmailCount
2.13 seeGetEmailFile
2.14 seeGetEmailLines
2.15 seeGetEmailSize
2.16 seeGetEmailUID
2.17 seeIntegerParam
2.18 seePop3Connect
2.19 seeRelease
2.20 seeSendEmail
2.21 seeSmtpConnect
2.22 seeStatistics
2.23 seeStringParam
2.24 seeVerifyFormat
2.25 seeVerifyUser
All functions return an integer code. Negative values are always errors. See Section 10.3 "SEE Error Return Code List" in the SEE/POP3 Users Manual (SEE_USR). Non-negative return codes are never errors.
Note that the seeErrorText function is used to get the text message associated with any error code.
Each function argument is marked as:
(I) : 2-byte integer (Win16), 4-byte integer (Win32).
(L) : 4-byte integer (Win16 and Win32).
(P) : 4-byte pointer (Win16 and Win32).
Refer to the declaration files (see section 1.3 below) for the exact syntax of each SEE function. Also note that the example programs show exactly how SEE functions are called.
The complete set of documentation consists of three manuals in three formats. This is
the third manual
(SEE_REF) in the set.
Each manual comes in three formats:
The exact syntax for calling SEE functions are specfic to the host language (C/C++, Delphi, VB, etc.) and are defined for each language in the “SEE declaration files”. Each SEE product comes with the appropriate declaration file for the supported language. For example,
SEE4C C/C++ SEE.H SEE4VB Visual Basic SEE16.BAS and SEE32.BAS VBA (EXCEL,ACCESS,etc.) SEE16.BAS and SEE32.BAS SEE4PB PowerBASIC SEE32.BAS [not the same as above] SEE4D Borland Delphi SEE16.PAS and SEE32.PAS SEE4CB Fujitsu COBOL SEE32.CBI SEE4F ABSOFT FORTRAN SEE32.INC SEE4FP Visual FoxPro SEE32.FOX SEE4DB Visual dBase SEE16.CC and SEE32.CCAll SEE functions are used in one or more example programs.
NbrChans : (I) Number of channels or threads.
KeyCode : (L) Registration key code.
The seeAttach function must be the first SEE call made. Pass the maximum number of channels or threads that will be in use. Use NbrChans = 1 for non-threaded applications.
The 'Chan' parameter for subsequent calls to SEE functions must be in the range of 0 to NbrChans-1.
In WIN32, up to 128 threads (numbered from 0 to 127) can be started, each of which can be connected to a different server and run independently.
When SEE is registered, you will receive a 'KeyCode' which matches the 'KeyCode' within the registered DLL. For the shareware version, the keycode is 0. See file KEYCODE.
All example programs call seeAttach.
seeSmtpConnect and seePop3Connect.
seeCommand(Chan, Text)
Chan : (I) Channel number.
Text : (I) Command.
The seeCommand function sends the command in 'Command' to the SMTP or POP3 server after connecting.
The seeCommand function is designed to allow the user to send commands that are specific to a particular SMTP or POP3 server. It can also be used to send SMTP or POP3 commands that are not implemented in the SEE library.
Call seeDebug with SEE_GET_LAST_RESPONSE in order to get the text of the server's response.
Refer to the HELLO example program for an example.
seeSmtpConnect and seePop3Connect.
seeClose(Chan)
Chan : (I) Channel number.
The seeClose function closes the connection created by calling seeSmtpConnect or seePop3Connect. seeSmtpConnect or seePop3Connect can be called again to open a connection to another SMTP or POP3 server if desired.
SEE can not be connected to both the SMTP server and the POP3 server at the same time (unless you are using threads). Call seeClose to terminate the connection before connecting again.
If seeSmtpConnect (or seePop3Connect) fails, do not call seeClose.
All example programs call seeClose.
seeSmtpConnect and seePop3Connect
seeDebug(Chan, Index, Buffer, BufLen)
Chan : (I) Channel number.
Index : (I) Command index.
Buffer : (P) Buffer to place text into.
BufLen : (I) Length of above Buffer.
The seeDebug function returns (textual) debug information depending on the value of Index.
SEE_GET_REGISTRATION : Gets the registration string.
SEE_GET_LAST_RESPONSE : Gets last server response.
SEE_GET_SERVER_IP : Get server IP address in dotted notation.
SEE_COPY_BUFFER : Copies internal buffer. See seeGetEmailLines.
See SEEVER example program.
seeStatistics
seeDecodeBuffer(CodedPtr, ClearPtr, Length)
CodedPtr : (P) Buffer of base-64 coded chars.
ClearPtr : (P) Buffer to put decoded bytes.
Length : (I) Length of above buffer.
The seeDecodeBuffer function decodes the buffer 'CodedPtr' of length 'Length' into 'ClearPtr', returning the length in 'ClearPtr'.
The buffer 'CodedPtr' MUST contain base-64 encoded text, as created by seeEncodeBuffer.
The buffer 'ClearPtr' will contain the ASCII or binary data that was encoded.
Number of bytes in ClearPtr.
See the CODETEST example program.
seeEncodeBuffer.
seeDeleteEmail(Chan, MsgNbr)
Chan : (I) Channel number.
MsgNbr : (I) Message number.
The seeDeleteEmail function deletes the email numbered 'MsgNbr' from the server.
The first message is always number 1. Call seeGetEmailCount first to get the number of email messages on the server.
Be careful! Once an email has been deleted from the server, it cannot be recovered.
See the READER example program.
seeGetEmailUID and seeGetEmailCount
seeDriver(Chan)
Chan : (I) Channel number.
The seeDriver function executes the next state in the SEE state engine. The purpose of this function is to allow the programmer to get control after the driver executes each state.
The seeDriver function is explicitly called only after the AUTO_DRIVER_CALL flag has been disabled (see function seeIntegerParam). If the AUTO_DRIVER_CALL flag has not been disabled (the default), then seeDriver does not need to be called.
Refer to the section 4 "Theory of Operation" in the SMTP/POP3 Users Manual (SEE_USR) for more details on the operation of seeDriver.
See the READER example program.
seeIntegerParam, seeSmtpConnect, and seePop3Connect.
seeEncodeBuffer(ClearPtr, CodedPtr, Length)
ClearPtr : (P) Buffer of characters to encode.
CodedPtr : (P) Buffer to put base-64 encoded.
Length : (I) Length of above.
The seeEncodeBuffer function encodes 'ClearPtr' into 'CodedPtr' using Base-64 encoding.
The 'ClearPtr' buffer may contain any ASCII or binary data.
The 'CodedPtr' buffer will contain 7-bit ASCII data broken into lines of 76 characters followed by a carriage return (hex 0D) and line feed (hex 0A). That is, 'CodedPtr' will contain multiple lines.
Number of bytes in CodedPtr.
See the CODETEST example program.
seeIntegerParam, seeSmtpConnect, and seePop3Connect.
seeErrorText(Chan, Code, Buffer, BufLen)
Chan : (I) Channel number.
Code : (I) Error code returned by SEE function.
Buffer : (P) Buffer to place error text into.
BufLen : (I) Length of above Buffer.
The seeErrorText function is used to get the error text associated with an error code as returned by one of the other SEE functions.
When an error occurs, seeErrorText can be used to get the error text so that it can be displayed for the user.
Most example programs call seeErrorText.
seeExtractLine(Src, Line, Buffer, BufSize)
Src : (P) Text buffer to search.
Line : (I) Line number (1,2,...) wanted.
Buffer : (P) Buffer for line if found.
BufSize : (I) Size of 'Buffer'.
The seeExtractLine function is used to extract line 'Line' from buffer 'Src'. If found, the entire line is copied to 'Buffer', up to a maximum of 'BufSize' bytes.
The primary purpose of seeExtractLine is to extract header lines (by line number) from the buffer after calling seeGetEmailLines. Recall that all lines returned by seeGetEmailLines are terminated by a carriage return, linefeed pair. Lines are numbered from 1 rather than 0.
The seeExtractLine does not require a connection to a SMTP or POP3 server.
Number of bytes placed in 'Buffer'.
See the example program STATUS.
seeGetEmailLines and seeExtractText.
seeExtractText(Src, Text, Buffer, BufSize)
Src : (P) Text buffer to search.
Text : (P) Text searching for.
Buffer : (P) Buffer for line if found.
BufSize : (I) Size of 'Buffer'.
The seeExtractText function is used to search the text buffer 'Src' for text 'Text'. If found, the entire line is copied to 'Buffer', up to a maximum of 'BufSize' bytes.
The primary purpose of seeExtractText is to extract header lines from the buffer after calling seeGetEmailLines. Recall that all lines returned by seeGetEmailLines are terminated by a carriage return, linefeed pair.
The seeExtractText does not require a connection to a SMTP or POP3 server.
Number of bytes placed in 'Buffer'.
See the example programs STATUS and FROM.
seeGetEmailLines and seeExtractLine.
seeGetEmailCount(Chan)
Chan : (I) Channel number.
The seeGetEmailCount function returns the number of messages waiting on the server, independent of whether they have been previously read.
If you have disabled the driver AUTO_CALL capability, the message count must be found by calling
seeStatistics(0, SEE_GET_MSG_COUNT)
after calling seeDriver until it returns 0.
See the STATUS example program.
seeGetEmailLines.
seeGetEmailFile(Chan, MsgNbr,EmailName,EmailDir,AttachDir)
Chan : (I) Channel number. MsgNbr : (I) Header #. EmailName : (P) Email filename. EmailDir : (P) Directory for email. AttachDir : (P) Directory for attachments.
The seeGetEmailFile reads the email message 'MsgNbr', saving it to disk as filename 'EmailName' in directory 'EmailDir', and saving MIME attachments to directory 'AttachDir'. The current directory is specified as '.'.
Be sure that the specified directories exist before calling this function. Use '.' to specify the current directory.
Also note that a older file of the same name as being saved will be overwritten by the newer file.
See the READER example program.
seeGetEmailLines.
seeGetEmailLines(Chan, MsgNbr, Lines, Buffer, Size)
Chan : (I) Channel number.
MsgNbr : (I) Message #.
Lines : (I) Number of lines.
Buffer : (P) Pointer to (static) Buffer.
Size : (I) Size of buffer.
The seeGetEmailLines function reads all header lines plus the number of body lines specified by the 'Lines' argument into 'Buffer', up to a maximum of 'Size' bytes.
The primary purpose of this function is to read the header lines without having to read the entire message. If you have disabled the driver AUTO_CALL capability, the size must be found by calling
seeStatistics(Chan, SEE_GET_BUFFER_COUNT)
after calling seeDriver until it returns 0.
If a 0 is passed as the 4th argument (Buffer), the SEE will use an internal buffer, the contents of which can be accessed by subsequently calling seeDebug(Chan, SEE_COPY_BUFFER,. . .). This technique is ONLY necessary in direct mode (calling seeDriver directly) from languages (such as Visual Basic, dBase 2000, etc.) that cannot statically allocate memory. Refer to the SEE Programmer's Manual.
See the STATUS example program.
seeGetEmailFile
seeGetEmailSize(Chan, MsgNbr)
Chan : (I) Channel number.
MsgNbr : (I) Message number
The seeGetEmailSize function returns the size in bytes of the specified message 'MsgNbr'.
seeGetEmailSize returns the size of the entire email message, including any attachments. Note that attachments will be encoded (MIME, UUENCODE, etc.), and thus take up more room than after they are decoded.
If you have disabled the driver AUTO_CALL capability, the size must be found by calling
seeStatistics(0, SEE_GET_MSG_SIZE)
after calling seeDriver until it returns 0.
See the STATUS and READER example programs.
seeGetEmailCount.
seeGetEmailUID(Chan, MsgNbr, Buffer, Size)
Chan : (I) Channel number.
MsgNbr : (I) Message (-1 for all) number.
Buffer : (P) Pointer to Buffer.
Size : (I) Size of buffer.
The seeGetEmailUID function is used to ask the POP3 server for the unique user ID string for a particular email message, or for all email messages on the server.
The UID string is always the same for a particular email message, regardless of the email message number.
Most POP3 servers can provide such a unique ID string. A few POP3 servers do not provide ID strings.
See the READER example program.
seeGetEmailCount.
seeIntegerParam(Chan, ParamIndex, ParamValue)
Chan : (I) Channel number. ParmIndex : (I) Parameter index (see below). ParmValue : (L) Value of parameter to set.
The seeIntegerParam is used to set an integer parameter as defined in the SEE declaration file. Refer to Section 1.3 “Declaration Files”. For more information on using this function, refer to Section 3.3.1 of SEE_USR. All times are in milliseconds. Defaults values are as follows:
SEE_MIN_RESPONSE_WAIT : 250 SEE_MAX_RESPONSE_WAIT : 25000 SEE_MIN_LINE_WAIT : 0 SEE_MAX_LINE_WAIT : 25000 SEE_CONNECT_WAIT : 60000 SEE_QUOTED_PRINTABLE : 0 [FALSE] SEE_AUTO_CALL_DRIVER : 1 [TRUE] SEE_FILE_PREFIX : 0 [FALSE] SEE_MAX_SMTP_WAIT : 500 SEE_MAX_POP3_WAIT : 500 SEE_SLEEP_TIME : 50 SEE_DECODE_UNNAMED : 0 [FALSE] SEE_MAX_LINE_LENGTH : 76 SEE_ALLOW_8BITS : 0 [FALSE] SEE_HIDE_SAVED_MSG : 0 [FALSE] SEE_HIDE_TO_ADDR : 0 [FALSE] SEE_SMTP_PORT : 25 SEE_POP3_PORT : 110 SEE_ADDRESS_DELIMITER : ',' [comma]
SEE_MIN_RESPONSE_WAIT is the delay before looking for the server's response.
SEE_MAX_RESPONSE_WAIT is the time after which a "time-out" error occurs if the server has not responded.
SEE_MIN_LINE_WAIT is the delay before checking if the server is ready to accept the next line of input.
SEE_MAX_LINE_WAIT is the time after which a "time-out" error is declared if the server has not responded.
SEE_CONNECT_WAIT is the maximum time allowed to complete a connection to the SMTP server.
SEE_FILE_PREFIX controls whether "1-", "2-", etc. is prefixed to the filename of each attachment. If two attachments are named FILEONE.ZIP and FILETWO.ZIP, they will be saved as 1-FILEONE.ZIP and 2- FILETWO.ZIP.
Note that Windows 3.1 may truncate long filenames. This feature should always be used unless you are downloading to a directory specifically for downloaded attachments.
SEE_QUOTED_PRINTABLE controls whether messages are or are not encoded as quoted-printable. Use QUOTED_OFF (0) to disable quoting, QUOTED_PLAIN (1) to enable normal quoting, and QUOTED_HTML (2) to enabled quoting of embedded HTML text.
SEE_AUTO_CALL_DRIVER controls whether seeDriver is called automatically (to completion) after seeSmtpConnect or seePop3Connect has been called.
SEE_SLEEP_TIME is the time SEE sleeps when waiting on a Winsock (WIN32 only).
SEE_DECODE_UNNAMED will force (if non-zero) decoding of all base64 attachments which do not have names.
SEE_MAX_LINE_LENGTH specifies the maximum length of the lines sent to the SMTP server. Note that the RFC822 standard specifies 76 characters.
SEE_ALLOW_8BITS will allow 8-bit data inside an email message. Note that 7-bit ASCII is the RFC822 standard. Not recommended!
SEE_HIDE_SAVED_MSG is used to hide the "Attachment saved to " message in incoming email.
SEE_HIDE_TO_ADDR is used to hide the "To:" field in outgoing email.
SEE_SMTP_PORT and SEE_POP3_PORT changes the SMTP or POP3 port.
SEE_ADDRESS_DELIMITER sets the delimiter to use for separating multiple email addresses.
Most of the example programs call seeIntegerParam.
seeStringParam.
seePop3Connect(Chan, Pop3Ptr, UsrPtr, PassPtr)
Chan : (I) Channel number.
Pop3Ptr : (P) POP3 server name
UserPtr : (P) POP3 user name.
PassPtr : (P) POP3 password.
The seePop3Connect function establishes a connection with the POP3 server as specified by the Server argument.
Your POP3 server name will typically be named "mail.XXX.com" where XXX is your email
address, such
as
name@XXX.com. Your POP3 server name can also be found in the setup information for your
normal
email client, such as Eudora or Microsoft Outlook.
The POP3 server name can also be specified in dotted decimal notation if wanted. For example, "10.23.231.1".
SEE can not be connected to both the SMTP server and the POP3 server at the same time. Call seeClose to terminate the connection before connecting again
See the STATUS and READER example programs.
seeSmtpConnect and seeClose.
seeRelease
The seeRelease function releases the SEE system. This should be the very last function called.
seeClose should be called for all channels before calling seeRelease.
Most all of the example programs call seeRelease.
seeAttach.
seeSendEmail(Chan, To, CC, BCC, Subj, Msg, Attach)
Chan : (I) Channel number.
To : (P) Recipient, separated by commas.
CC : (P) CC list, separated by commas.
BCC : (P) BCC list, separated by commas.
Subj : (P) Subject text.
Msg : (P) Message or message filename.
Attach : (P) File attachment.
The seeSendEmail function is used to send email once a connection has been made to your SMTP server after calling seeSmtpConnect.
Note that all email addresses (in To, CC, and BCC strings) must be bracketed. For example:
<mike@marshallsoft.com>
The CC and BCC strings may contain multiple email addresses, separated by commas. For example,
"Billy Bob<bbob@isp.com>,Buster<bm@isp.com>"
If the first character of the message (fifth argument) is a '@', then it is considered as the filename which contains the message to send.
'Attach' may contain one or more attachments, separated by commas. For example,
"file1.zip,file2.doc".
See the MAILER example program.
seeSmtpConnect.
seeSmtpConnect(Chan, Server, From, ReplyTo)
Chan : (I) Channel number.
Server : (P) SMTP server.
From : (P) Your email address in brackets.
ReplyTo : (P) Email address to reply to.
The seeSmtpConnect function establishes a connection with the SMTP server as specified by the 'Server' argument.
Your SMTP server name will typically be named "mail.XXX.com" where XXX is your email address, such as name@XXX.com. Your SMTP server name can also be found in the setup information for your normal email client, such as Eudora or Microsoft Outlook.
The SMTP server name can also be specified in dotted decimal notation if wanted. For example "10.23.231.1".
The 'From' string is required and must be enclosed in "<>" brackets, such as <mike@marshallsoft.com>.
The 'ReplyTo' string is optional and is used for the "Reply-To:" header line. If used, the email address must be enclosed in "<>" brackets.
SEE can not be connected to both the SMTP server and the POP3 server at the same time. Call seeClose to terminate the connection before connecting again.
See the MAILER example program.
seeClose.
seeStatistics(Chan, Index)
Chan : (I) Channel number.
Index : (I) Specifies which statistic.
The seeStatistics function is used to return runtime statistics in the SEE DLL. The values of 'Index' are defined in the SEE declaration file (see Section 1.3 “Declaration Files”) as follows. For more information on language specific declaration files, refer to the SEE Users Manual (SEE_USR).
SEE_GET_ATTACH_BYTES_READ : Gets attachment bytes read. SEE_GET_ATTACH_BYTES_SENT : Gets attachment bytes sent. SEE_GET_ATTACH_COUNT : Gets attachments received. SEE_GET_ATTACH_NAME : Gets list of attachment file names. SEE_GET_BUFFER_COUNT : Gets bytes in buffer for seeGetEmailLines. SEE_GET_BUILD : Gets version build number. SEE_GET_CONNECT_STATUS : Returns TRUE if connected. SEE_GET_COUNTER : Gets times driver called. SEE_GET_MESSAGE_BYTES_READ : Gets message bytes read. SEE_GET_MESSAGE_BYTES_SENT : Gets message bytes sent. SEE_GET_MSG_COUNT : Gets emails waiting. SEE_GET_MSG_SIZE : Gets size of email. SEE_GET_RESPONSE : Gets last SMTP response code. SEE_GET_SOCK_ERROR : Gets last socket error. SEE_GET_TOTAL_BYTES_READ : Gets total bytes read. SEE_GET_TOTAL_BYTES_SENT : Gets total bytes sent. SEE_GET_VERSION : Gets the SEE version number.
The number of message bytes sent will usually be larger than your message size because of SMTP protocol overhead.
The number of attachment bytes sent will be at least one-third larger than the actual attachment since every three (3) bytes are encoded as four (4) 7-bit ASCII bytes before being transmitted.
The purpose of " BYTES_READ" and " BYTES_SENT" is to provide the ability to track the transmission progress of large messages and attachments. program.Chan : (I) Channel number. ParamName : (I) Index of parameter. ParamString: (P) Parameter string.
SEE_LOG_FILE : Specifies the log filename.
SEE_SET_REPLY : Sets the "Reply To" string.
SEE_SET_HEADER : Adds header line(s).
The log file is used to debug a SMTP or POP3 session. Be advised that log files can be quite large. Don't use them unless necessary.
Use SEE_SET_REPLY to change the "Reply-To:" header after connecting to the server, just before sending an email.
Use SEE_SET_HEADER to add one or more header lines. Each header line except the last should end with a carriage return line feed pair.
Most example program call seeStringParam.
seeIntegerParam.
seeVerifyFormat(String)
String : (P) Email address to check.
The seeVerifyFormat function is used to test an individual email address for proper formatting. If this function returns 0 or above, then the email address is properly formatted. But, if this function returns a negative value, the email address is either badly formatted, or it uses characters (such as '%') that are not normally used as part of an email address.
Note that left and right brackets ('<' and '>') must surround the email address.
See the VERUSR example program.
seeErrorText and seeVerifyUser.
seeVerifyUser(Chan, String)
Chan : (I) Channel number.
String : (P) Email address to verify.
The seeVerifyUser function is used to verify an individual email address with the email server which "owns" the email address.
seeVerify will connect to the specified server and request verification of the user. Some SMTP servers may refuse connection of any client not directly connected to them or may refuse all "verify user" requests. Web based email servers such as hotmail.com may refuse all SMTP connections.
Note that you connect to the remote SMTP server rather than the SMTP server that you use to send email.
For example, to verify msc@traveller.com, you must first connect to the SMTP server "mail.traveller.com" then call SeeVerifyUser(0, "msc").
See the VERUSR example program.
seeErrorText and seeDebug.