bool send_mail(char *from, char *to, char *bcc, char *subject, char *body)
{
char command[TMP_PART_SIZE];
FILE* mail;
syslog (LOG_NOTICE, "Sending_mail\n");
snprintf(command, sizeof(command), "%s -t %s", SENDMAIL_LOCATION, to);
if ((mail = popen(command, "w")) == NULL) {
perror("popen()");
return false;
}
else
{
fprintf(
mail,
"Subject: %s\nFrom: %s\nTo: %s\nBcc: %s\nContent-Type: text/plain; charset=windows-1251\n\n%s\n.\n",
subject,
from,
to,
bcc,
body
);
if (pclose (mail)) {
syslog (LOG_NOTICE, "Sending_failed\n");
}
return true;
}
}
|