I am trying to send an email via mail command in linux c++, but execl is causing errors.
How do I send this command with exec?
/bin/echo llol | /usr/bin/mail -s "testt" [email protected]
Thanks.
Here is the code:
void AppConfig::sendEmail(string to, string subject, string body)
{
stringstream ss;
ss << "/bin/echo " << body << " | /usr/bin/mail -s \"" << subject << "\" " << to;
cout << ss.str();
cout << "rofl";
errno = 0;
int ret = execl(ss.str().c_str(), "", (char*) 0);
cout << "ret=" << ret << " errno=" <<errno;
}
I get errno=2(directory not found).