diff options
Diffstat (limited to 'tests/test_mailto.c')
-rw-r--r-- | tests/test_mailto.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/test_mailto.c b/tests/test_mailto.c new file mode 100644 index 0000000..30cb54b --- /dev/null +++ b/tests/test_mailto.c @@ -0,0 +1,37 @@ +#include <stdio.h> +#include <stdlib.h> + +#include "comm.h" +#include "calls.h" + +static void callback( DapiConnection* a1, int a2, int a3 ) + { + (void) a1; + (void) a2; + (void) a3; + fprintf( stderr, "Unexpected async reply, ignoring.\n" ); + } + +int main() + { + int ok; + const char* attachments[] = { "/tmp/mailtotest.txt", NULL }; + DapiConnection* conn = dapi_connect(); + if( conn == NULL ) + { + fprintf( stderr, "Cannot connect!\n" ); + return 1; + } + dapi_setSyncCallback( conn, callback ); + if( !dapi_Init( conn )) + { + fprintf( stderr, "Initialization failed!\n" ); + return 2; + } + system( "touch /tmp/mailtotest.txt" ); + ok = dapi_MailTo( conn, "Test mail", "Hi,\n\nthis is a test mail.\n", + "l.lunak@suse.cz, l.lunak@kde.org", NULL, "portland@lists.freedesktop.org", attachments ); + printf( "Result: %s\n", ok == 1 ? "Ok" : "Failed" ); + dapi_close( conn ); + return 0; + } |