I have a working procmail config.
this is the rc.filters :
:0 w :a.lock
* ^From:(.*\<)?(try@gmail\.com)\>
| $HOME/executable/a.out
this file compiles and works, procmail delivers the mail, and the executable writes the content to the output file.
#include <stdlib.h>
#include <iostream>
#include <fstream>
using namespace std;
int main(void)
{
ofstream myfile;
myfile.open ("output.txt");
string line;
while (getline(cin, line))
{
myfile << line << endl;
}
myfile.close();
return EXIT_SUCCESS;
}
the problem is I need a cin object with the content to pass to a constructor of the Mimetic library. I need this executable to work:
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <mimetic/mimetic.h>
using namespace std;
using namespace mimetic;
int main(void)
{
ofstream myfile;
myfile.open ("output.txt");
MimeEntity me(cin);
const Header& h = me.header();
string subjectString = h.subject();
myfile << subjectString;
myfile << "Check";
myfile.close();
return EXIT_SUCCESS;
}
If I take a Mime message called message.txt and do the following with the second code :
cat message.txt | ./a.out
./a.out < message.txt
In both cases the executable works and I get the subject in an output.txt
but for some when it is invoked and the content piped by procmail it doesn't work,
and all I get in the output.txt is "Check" which means that the file
was at least invoked.
the procmail.log states that everything is fine.
I don't know what's going on exactly but I would capture the input from
std::cin
into a string and then pass astd::istringstream
constructed from that value toMimeEntity
. This way you can inspect what the input fromstd::cin
was while still having it processed by the library: