# Missing logical link in knowledge



## Seeker (Sep 1, 2009)

I've posted problem here.

Now that person implies that I need to gain unix knowledge on pipe.
I know what is pipe. I use it everyday to pipe data from one command to another.

So I have no idea what is missing link in my knowledge here.
That is, if I "figure" pipe I'll solve whole problem there...

Can you help me? :beergrin


----------



## DutchDaemon (Sep 1, 2009)

I have no idea why those people are hammering on about pipes. You're simply posting message headers and a message body on standard input (okay, call it a 'reverse pipe'), which is totally normal.

There's nothing wrong with using:


```
sendmail -G -i -f someone@domain someone_else@domain [enter] 
From: someone@domain 
To: someone_else@domain
Subject: test

test
[ctl-d]
```

or


```
sendmail -t someone_else@domain <<EOF [enter]
From: someone@domain
To: someone_else@domain
Subject: smth

smth
EOF [enter]
```
Of course, you can put this in a text file called 'content':


```
From: someone@domain 
To: someone_else@domain
Subject: test

test
```

and then run


```
cat content | sendmail -G -i -f someone@domain someone_else@domain
```

That's what you do if your email contents are already on file and just need to be piped through sendmail, but Sendmail doesn't mind whether you penetrate it from the front (pipe) or the back (standard input), so to speak ..


----------



## SirDice (Sep 1, 2009)

I think the postfix guys mean you cannot do 


```
sendmail -G -i -f someone@domain someone_else@domain <message+headers>
```

All on one line. That's why they're mentioning pipes. The solution is to use the last example DD gave.


----------



## aragon (Sep 1, 2009)

What is the problem anyway?


----------



## Seeker (Sep 1, 2009)

DUH!

Look here!

I've gave EXACT example, how do I use sendmail which is what DutchDeamon posted and which proves I've already KNEW that but they continued to hammer "solution is in pipe, which you do not understand, and when you do, EVERYTHING shall be solved" :stud

Time wasters! x(

And here is my final response to them


> True!
> 
> I've goofed searching man pipe, for BASE FreeBSD installation.
> AFTER I've installed postfix, then "man 8 pipe" became available!
> ...


----------



## Seeker (Sep 2, 2009)

There was some error when user, other than root, has been filtering mail.
Error was visible only when I manually executed:

```
# cat mail_in_file | ./mail_filter.php root@example1.com john@example2.com
[B]Syntax error: "(" unexpected[/B]
```
I simply changed php code related to execution of shell functions.
Finally, I've completely solved a problem.

_Now for a future reference:_
where I can find *Syntax error: "(" unexpected*, error logged, as it wasn't in postfix error log:
/var/log/maillog

Thanks in advance


----------



## bigearsbilly (Sep 28, 2009)

you are probably missing something like

*#!/usr/local/bin/php*

at line 0 on your php script.

dunno I ain't a php man.

or


```
cat mail_in_file | [B]php[/B] ./mail_filter.php  root@example1.com john@example2.com
```

logged in as root eh?


----------



## Seeker (Sep 28, 2009)

At line 0...,  it has always been there.
And I've solved this long ago and everything is working smoothly now.
Thanks!


----------



## phoenix (Sep 28, 2009)

Please post the solution for the archives.


----------



## Seeker (Sep 30, 2009)

Shell was one that echoed *Syntax error: "(" unexpected*, because it didn't liked a way PHP "treated" it.
So I've simply used other PHP function for comunnication with shell.
Instead of just executing command like you would
	
	



```
ls -al
```
, I've used PHP's popen to open pipe to sendmail

```
$po = popen(/usr/local/sbin/sendmail -some_param, 'w');
```
And then were writing mail to *$po*
Voila!


----------

