FILE *fp;
char cmd[200];
char to[] = "user@host";
char subject[] = "testing 1 2 3";
sprintf( cmd, "mail -s %s %s", subject, to );
fp = popen( cmd, "w" );
fprintf( fp, "Hello world\n" ); // the message to send
pclose( fp );