Greyware Mail DLL (GWMail32) is a programmers' tool that lets you add SMTP email functionality to
your programs quickly and easily. You don't have to know anything about SMTP to use the
DLL -- just add it to your project like any other DLL and call its functions.
Greyware Mail DLL handles all the complexity of Winsock communications and the SMTP/ESMTP protocols.
Greyware Mail DLL is designed to be as bullet-proof and easy-to-use as possible. It uses
intelligent defaults, and provides clear plain-English error messages. You can send a message
or a file (or both at the same time) with only one function call. Lets you send email
with as little as one line of code!
Requirements
This program requires Win95, Win98, NT 3.51, 4.0, or Windows 2000.
This program also requires that you have TCP/IP installed and properly
configured on your machine. If your SMTP host is not on your local network (say, for example,
that you use a dial-up connection to the Internet for email), then you must go online and
establish your PPP or SLIP session before using Greyware Mail DLL. If your machine is
configured to connect on demand via dial-up, then using Greyware Mail DLL will bring up the dial-up
connection automatically.
Setup and Installation
GWMail32 is a Windows DLL (gwmail32.dll). To install it, simply copy it to the SYSTEM32
directory (SYSTEM directory on Win95 or Win98) or your application's directory. It does not
need to be registered or configured, does not use the registry, and has no options. All of
the parameters are set through the provided API, under the control of your own program.
Version History
1.4.b.20000528 - added support for multiple SMTP hosts; added support for non-standard SMTP
port numbers; fixed bug that could cause sending email to hang if the SMTP server responds
with non-standard responses to SMTP commands. Added #ifdef __cplusplus syntax to
gwmail32.h to
assist those compiling in a mixed C and C++ environment.
1.3.b.20000306 - added < and > to RCPT TO (to comply with RFC 821 for older servers)
1.3.b.19991210 - added code to strip redundant CRLFs after the message body
1.3.b.19990510 - Alpha version released
1.2.b.980306 - added support for non-cannonical email names
1.2.b.980227 - first public release
1.1.b.970104 - added simplified declarations for common functions
1.0.b.960203 - internal use release. Basic functionality established
Notes
Multiple SMTP hosts: As of version 1.4, you may specify more than one SMTP host. The
DLL will try them in order, and use the first host that responds. Separate hosts with
a comma or semicolon. For example:
smtp.yourhost.com;fallback1.yourhost.com;fallback2.yourhost.com
// tries smtp.yourhost.com first; if server unavailable, tries fallback1.yourhost.com;
// if fallback1 unavailable, tries fallback2, etc.
Specified SMTP ports: As of version 1.4, you may specify the SMTP port for each host.
If you do not specify a port, the DLL will use the RFC-specified port 25. To force the
DLL to use a port other than 25, add it to the end of the host name with a colon. For
example:
smtp.yourhost.com:2525 // uses port 2525 instead of port 25
smtp.yourhost.com;smtp.yourhost.com:2525 // tries port 25 first, then port 2525
Decorated Names: The DLL supports either standard or decorated email addresses.
A standard email address is one with a username, at-sign, and host/domain. Example: sales@greyware.com
A decorated email address includes information for the recipient's email client to display
instead of the plain email address. The DLL supports two variations of decorated names:
Example 1: Sales Department <sales@greyware.com>
Example 2: "Sales Department" sales@greyware.com
The email will be delivered to sales@greyware.com, but most email clients will show the
address as Sales Department.
The main documentation for the various calls may be found within the comments of the
C/C++ include file, gwmail32.h.
Declarations for other languages may easily be derived from the information in gwmail32.h.
If your project is written using C or C++, then you may want to include the LIB file,
gwmail32.lib in
your project at compile time. You may also use Win32's LoadLibrary() function to
use the DLL dynamically.
If your project is written using Visual Basic, you might find this sample program helpful:
gwmail.frm which
uses declarations in gwmail.bas.
Any other VB declarations can be derived from the information in gwmail32.h.
Sample C Program
#include <windows.h>
#include <stdio.h>
#include gwmail32.h
//
// link with kernel32.lib, user32lib, and gwmail32.lib
//
//
// compile as a CONSOLE program
//
// sample program showing SendSMTPEx syntax in use--
// be sure to change the parameters to reflect YOUR
// setup!
int main(void)
{
DWORD dwResult;
char szError[128];
//
// send a quick test message
//
dwResult = SendSMTPMessage(
"smtp.greyware.com", // SMTP Host
"jeffryd@greyware.com", // From
"sales@greyware.com", // To
"Test of GWMail32", // Subject
"Just a message...."); // Message
//
// display the results
//
GWMailFormatMessage(dwResult,szError,sizeof(szError));
printf("SendSMTPMessage result: %s\n",szError);
if (dwResult != ERROR_SUCCESS) return dwResult;
//
// send a quick file
//
dwResult = SendSMTPFile(
"smtp.greyware.com", // SMTP Host
"jeffryd@greyware.com", // From
"sales@greyware.com", // To
"c:\\boot.ini"); // Filename
//
// display the results
//
GWMailFormatMessage(dwResult,szError,sizeof(szError));
printf("SendSMTPMessage result: %s\n",szError);
if (dwResult != ERROR_SUCCESS) return dwResult;
//
// send some email; include an attached file in
// uuencode format just for fun
dwResult = SendSMTPEx(
"smtp.greyware.com", // SMTP Host
"jeffryd@greyware.com", // From
"sales@greyware.com", // To
"techsupport@greyware.com", // Cc
NULL, // Bcc, NULL = none
"Test of GWMail32", // Subject
NULL, // Errors-To (not used)
NULL, // Reply-To (not used)
"This is a test message.", // The message
"c:\\boot.ini", // Attached File
FALSE, // don't bother with DOS name
ENCODING_UUENCODE); // use UUENCODE
//
// display the results
//
GWMailFormatMessage(dwResult,szError,sizeof(szError));
printf("SendSMTPEx result: %s\n",szError);
return dwResult;
}