Back to Kbengine

jwSMTP How To

kbe/src/lib/dependencies/jwsmtp/docs/usage.html

2.5.121.7 KB
Original Source

How To Use the jwSMTP library in your own programs

The easiest way to use jwSMTP is to use the pkg-config program. Chances are this is already on your system. As an example you have a file (myemailingprogram.cpp) that you wish to compile into an smtp enabled program ( Please note that the [`] character in this line is not a ['] character ). Just run at the command line

g++ myemailingprogram.cpp -o myemailingprogram `pkg-config --libs --cflags jwsmtp-<version>`

where <version> is the latest version of jwSMTP without the <> symbols.
This compiles the program myemailingprogram , drop this file in a directory somewhere in your path, simple huh

One caveat this pre-supposes that the PKG_CONFIG_PATH environment variable is set correctly. If not set it at the command line. Please note that the [`] character in these lines is not a ['] character.

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig

g++ myemailingprogram.cpp -o myemailingprogram `pkg-config --libs --cflags jwsmtp-<version>`

where <version> is the latest version of jwSMTP without the <> symbols.
/usr/local/lib/pkgconfig being the path to the pkg-config directory where jwSMTP's pkg-config file is.

Alternatively if you do not have the pkg-config program

g++ myemailingprogram.cpp -o myemailingprogram -I/usr/local/include/jwsmtp-<version> -L/usr/local/lib -ljwsmtp-<version>

where <version> is the latest version of jwSMTP without the <> symbols.
If you wish to link statically

g++ myemailingprogram.cpp -o myemailingprogram -I/usr/local/include/jwsmtp-<version> /usr/local/lib/libjwsmtp-<version>.a

where <version> is the latest version of jwSMTP without the <> symbols.

email me about