jolle-pe
Posts: 10
Joined: Wed Jan 02, 2013 1:56 pm

Problems with mailx in c++

Tue Jan 06, 2015 12:54 pm

Hi,

I got a problem with my c++ Program. It uses the mailx package for email notification.

When I type in the terminal the email will arrive the reciever.

Code: Select all

cat helloworld.txt| mailx -s 'This is the subject' johndoe@gmx.de
But when I try it in my c++ program with the following programcode, it doenst receive, nor any error will show up:

Code: Select all

system("cat helloworld.txt| mailx -s 'This is the subject' johndoe@gmx.de");
Does anyone have a clue whats wrong?

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Problems with mailx in c++

Tue Jan 06, 2015 4:23 pm

It worked OK for me in a simple c program.

Code: Select all

#include <stdio.h>
#include <strings.h>
#include <stdlib.h>

void main () {
system("cat ~/hw.txt | mailx -s 'This is a test' pi@raspberry");
}
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Return to “C/C++”