Sending email to a User from C++

How do i send a mail to User from c++?

Its quite easier to use system command,though not recommended,

#include <iostream>
#include <string>
using namespace std;
int main(int argc,char** argv) {
    string mail_cmd("/path/to/mailx");
    string mail_options(" -s SUB:Test UserName");
    string mail_file_input(" < /tmp/message");
    string mail = mail_cmd+mail_options+mail_file_input;
    cout << "Command to be executed " << mail << endl;
    system(mail.c_str());
   return(0);
} 

Thanks
Nagarajan G