469,283 Members | 2,303 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,283 developers. It's quick & easy.

Mail2PHP

I want to send an email directly to a directory on my server
what script do I need to do this?
Maybe I should add a line to my aliases file like this: emailaddress:
"|/usr/bin/email2directory" ?
Thanks for some suggestions
Jul 16 '05 #1
10 3564
in your aliases enter a line such as:

mailprog: "|/usr/local/bin/php /path/to/your/file.php"

The below script will read the entire email recieved and store it in $buffer
for you do do what you want with it...

<?php
define('STDIN',fopen("php://stdin","r"));
//define('STDIN',fopen("dev/stdin","r"));
$str = fgets(STDIN);

$fp = popen('cat /dev/fd/0','r');
while(!feof($fp)) {
$lines = fgets($fp,4096)."\n";
}

$handle = STDIN;
while (!feof ($handle)) {
$buffer .= fgets($handle, 4096);
echo $buffer;
}
fclose ($handle);

// Rest of Script to manipulate the recieved email...

?>

HTH,

Brian...

"Lukas" <Lu***@verwijderdit.be> wrote in message
news:3f*********************@reader0.news.skynet.b e...
I want to send an email directly to a directory on my server
what script do I need to do this?
Maybe I should add a line to my aliases file like this: emailaddress:
"|/usr/bin/email2directory" ?
Thanks for some suggestions

Jul 16 '05 #2

"Brian McGarvie" <br************@nospam.anypurposeloans.co.uk> schreef in
bericht news:be**********@sparta.btinternet.com...
in your aliases enter a line such as:

mailprog: "|/usr/local/bin/php /path/to/your/file.php"

where can I find the exact path of php? It's not on this location :-(
Jul 16 '05 #3

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Whilst lounging around on Sat, 5 Jul 2003 11:35:09 +0200, "Lukas"
<Lu***@verwijderdit.be> amazingly managed to produce the following
with their Etch-A-Sketch:

"Brian McGarvie" <br************@nospam.anypurposeloans.co.uk>
schreef in bericht news:be**********@sparta.btinternet.com...
in your aliases enter a line such as:

mailprog: "|/usr/local/bin/php /path/to/your/file.php"

where can I find the exact path of php? It's not on this location
:-(

$ locate php

or

$ find / -name php

HTH.
Regards,

Ian

-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0

iQA/AwUBPwaiT2fqtj251CDhEQIT8ACeOJG5Bco26og5etX+yP5oMJ 6SkjsAmweB
q5yo5advPNid9F+Pe3xg5giS
=fZ+V
-----END PGP SIGNATURE-----

--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.
Jul 16 '05 #4

"Ian.H [dS]" <ia*@WINDOZEdigiserv.net> schreef in bericht
news:2h********************************@4ax.com...

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Whilst lounging around on Sat, 5 Jul 2003 11:35:09 +0200, "Lukas"
<Lu***@verwijderdit.be> amazingly managed to produce the following
with their Etch-A-Sketch:

"Brian McGarvie" <br************@nospam.anypurposeloans.co.uk>
schreef in bericht news:be**********@sparta.btinternet.com...
in your aliases enter a line such as:

mailprog: "|/usr/local/bin/php /path/to/your/file.php"

where can I find the exact path of php? It's not on this location
:-(

$ locate php

or

$ find / -name php

%locate php
/usr/local/www/bin/php-config
/usr/local/www/bin/phpextdist
/usr/local/www/bin/phpize
/usr/local/www/etc/php.ini-dist
/usr/local/www/include/php
/usr/local/www/include/php/TSRM
/usr/local/www/include/php/TSRM/TSRM.h
/usr/local/www/include/php/TSRM/acconfig.h
/usr/local/www/include/php/TSRM/readdir.h
/usr/local/www/include/php/TSRM/tsrm_config.h
/usr/local/www/include/php/TSRM/tsrm_config.w32.h
/usr/local/www/include/php/TSRM/tsrm_config_common.h
/usr/local/www/include/php/TSRM/tsrm_strtok_r.h
/usr/local/www/include/php/TSRM/tsrm_virtual_cwd.h
/usr/local/www/include/php/TSRM/tsrm_win32.h
/usr/local/www/include/php/Zend
/usr/local/www/include/php/Zend/-ZENDSHIT-
/usr/local/www/include/php/acconfig.h
/usr/local/www/include/php/ext
/usr/local/www/include/php/ext/standard
/usr/local/www/include/php/ext/standard/-STANDARDSHIT-
/usr/local/www/include/php/ext/xml
/usr/local/www/include/php/ext/xml/-XMLSHIT-
/usr/local/www/include/php/main
/usr/local/www/include/php/main/-MAINSHIT-
/usr/local/www/include/php/php_version.h
/usr/local/www/include/php/regex
/usr/local/www/include/php/regex/-REGEXSHIT-
/usr/local/www/lib/php
/usr/local/www/lib/php/Benchmark
/usr/local/www/lib/php/Benchmark/Iterate.php
/usr/local/www/lib/php/Benchmark/Timer.php
/usr/local/www/lib/php/Cache
/usr/local/www/lib/php/Cache/-CACHESHIT-
/usr/local/www/lib/php/Console
/usr/local/www/lib/php/Console/Getopt.php
/usr/local/www/lib/php/Crypt
/usr/local/www/lib/php/Crypt/CBC.php
/usr/local/www/lib/php/Crypt/HCEMD5.php
/usr/local/www/lib/php/DB
/usr/local/www/lib/php/DB/-DBSHIT-
/usr/local/www/lib/php/Date
/usr/local/www/lib/php/Date/Calc.php
/usr/local/www/lib/php/Date/Human.php
/usr/local/www/lib/php/File
/usr/local/www/lib/php/File/Find.php
/usr/local/www/lib/php/File/Passwd.php
/usr/local/www/lib/php/File/SearchReplace.php
/usr/local/www/lib/php/HTML
/usr/local/www/lib/php/HTML/Common.php
/usr/local/www/lib/php/HTML/Form.php
/usr/local/www/lib/php/HTML/IT.php
/usr/local/www/lib/php/HTML/ITX.php
/usr/local/www/lib/php/HTML/Page.php
/usr/local/www/lib/php/HTML/Processor.php
/usr/local/www/lib/php/HTML/Select.php
/usr/local/www/lib/php/HTML/Table.php
/usr/local/www/lib/php/HTTP
/usr/local/www/lib/php/HTTP/Compress.php
/usr/local/www/lib/php/HTTP.php
/usr/local/www/lib/php/Image
/usr/local/www/lib/php/Image/Remote.php
/usr/local/www/lib/php/Log
/usr/local/www/lib/php/Log/composite.php
/usr/local/www/lib/php/Log/file.php
/usr/local/www/lib/php/Log/mcal.php
/usr/local/www/lib/php/Log/observer.php
/usr/local/www/lib/php/Log/sql.php
/usr/local/www/lib/php/Log/syslog.php
/usr/local/www/lib/php/Log.php
/usr/local/www/lib/php/Mail
/usr/local/www/lib/php/Mail/RFC822.php
/usr/local/www/lib/php/Mail/sendmail.php
/usr/local/www/lib/php/Mail/smtp.php
/usr/local/www/lib/php/Mail.php
/usr/local/www/lib/php/Math
/usr/local/www/lib/php/Math/Fraction.php
/usr/local/www/lib/php/Math/Util.php
/usr/local/www/lib/php/Net
/usr/local/www/lib/php/Net/Curl.php
/usr/local/www/lib/php/Net/Dig.php
/usr/local/www/lib/php/Net/SMTP.php
/usr/local/www/lib/php/Net/Socket.php
/usr/local/www/lib/php/Numbers
/usr/local/www/lib/php/Numbers/Roman.php
/usr/local/www/lib/php/PEAR
/usr/local/www/lib/php/PEAR/Common.php
/usr/local/www/lib/php/PEAR/Installer.php
/usr/local/www/lib/php/PEAR/Packager.php
/usr/local/www/lib/php/PEAR/Uploader.php
/usr/local/www/lib/php/PEAR.php
/usr/local/www/lib/php/Payment
/usr/local/www/lib/php/Payment/Verisign.php
/usr/local/www/lib/php/Schedule
/usr/local/www/lib/php/Schedule/At.php
/usr/local/www/lib/php/XML
/usr/local/www/lib/php/XML/Parser.php
/usr/local/www/lib/php/XML/RPC
/usr/local/www/lib/php/XML/RPC/Server.php
/usr/local/www/lib/php/XML/RPC.php
/usr/local/www/lib/php/build
/usr/local/www/lib/php/build/acinclude.m4
/usr/local/www/lib/php/build/dynlib.m4
/usr/local/www/lib/php/build/dynlib.mk
/usr/local/www/lib/php/build/fastgen.sh
/usr/local/www/lib/php/build/library.mk
/usr/local/www/lib/php/build/ltlib.mk
/usr/local/www/lib/php/build/mkdep.awk
/usr/local/www/lib/php/build/pear.m4
/usr/local/www/lib/php/build/program.mk
/usr/local/www/lib/php/build/rules.mk
/usr/local/www/lib/php/build/rules_common.mk
/usr/local/www/lib/php/build/rules_pear.mk
/usr/local/www/lib/php/build/shtool
/usr/local/www/libexec/libphp4.so
/var/db/pkg/mod_php4-4.0.6_5
/var/db/pkg/mod_php4-4.0.6_5/+COMMENT
/var/db/pkg/mod_php4-4.0.6_5/+CONTENTS
/var/db/pkg/mod_php4-4.0.6_5/+DESC
/var/db/pkg/mod_php4-4.0.6_5/+DISPLAY
/var/db/pkg/phpMyAdmin-2.1.0
/var/db/pkg/phpMyAdmin-2.1.0/+COMMENT
/var/db/pkg/phpMyAdmin-2.1.0/+CONTENTS
/var/db/pkg/phpMyAdmin-2.1.0/+DESC
Jul 16 '05 #5

"Joshua Ghiloni" <jd***@SPAM.ME.AND.DIE.cwru.edu> schreef in bericht
news:be**********@eeyore.INS.cwru.edu...
Lukas wrote:
"Ian.H [dS]" <ia*@WINDOZEdigiserv.net> schreef in bericht
news:2h********************************@4ax.com...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Whilst lounging around on Sat, 5 Jul 2003 11:35:09 +0200, "Lukas"
<Lu***@verwijderdit.be> amazingly managed to produce the following
with their Etch-A-Sketch:
"Brian McGarvie" <br************@nospam.anypurposeloans.co.uk>
schreef in bericht news:be**********@sparta.btinternet.com...

>in your aliases enter a line such as:
>
>mailprog: "|/usr/local/bin/php /path/to/your/file.php"

where can I find the exact path of php? It's not on this location
:-(


[ snip lots of places php was found ]

You could also try $ which php
If that doesn't return anything then either a) php isn't in your path or
b) you don't have it installed as a binary, only a module.


Last login: Sat Jul 5 13:09:23 2003 from deurne.ox.be
Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
The Regents of the University of California. All rights reserved.
FreeBSD 4.4-RELEASE (SERVER) #0: Wed Aug 28 19:41:18 GMT 2002
%which php
php: Command not found.
%

bad luck? Other options for my problem?
Jul 16 '05 #6
"Lukas" <Lu***@verwijderdit.be> wrote in
news:3f*********************@reader0.news.skynet.b e:

"Joshua Ghiloni" <jd***@SPAM.ME.AND.DIE.cwru.edu> schreef in bericht
news:be**********@eeyore.INS.cwru.edu...
[snip]

Last login: Sat Jul 5 13:09:23 2003 from deurne.ox.be
Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
The Regents of the University of California. All rights
reserved.
FreeBSD 4.4-RELEASE (SERVER) #0: Wed Aug 28 19:41:18 GMT 2002
%which php
php: Command not found.
%


That should be

where php
try that...

Ken Robinson
Jul 16 '05 #7
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Whilst lounging around on Sun, 06 Jul 2003 10:56:24 GMT, Ken Robinson
<se**********@rbnsn.com> amazingly managed to produce the following
with their Etch-A-Sketch:
%which php
php: Command not found.
%


That should be

where php
try that...

Ken Robinson

[tk@morris:~]$ where php
bash: where: command not found

[tk@morris:~]$ which php
[tk@morris:~]$

Are you sure?

I get no results from 'which' as PHP isn't installed as a binary, but
results are still better than 'where' as shown by:
[tk@morris:~]$ which perl
/usr/bin/perl


Regards,

Ian

-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0

iQA/AwUBPwhVOGfqtj251CDhEQJI6wCgwCyOhsa8pnEx23kWB51iVV DrjGsAoMwK
Dy7bnzitBBaTMIuJHx4euzm+
=Kv3M
-----END PGP SIGNATURE-----

--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.
Jul 16 '05 #8
"Ian.H [dS]" <ia*@WINDOZEdigiserv.net> wrote in
news:08********************************@4ax.com:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Whilst lounging around on Sun, 06 Jul 2003 10:56:24 GMT, Ken Robinson
<se**********@rbnsn.com> amazingly managed to produce the following
with their Etch-A-Sketch:
> %which php
> php: Command not found.
> %


That should be

where php
try that...

Ken Robinson

[tk@morris:~]$ where php
bash: where: command not found

[tk@morris:~]$ which php
[tk@morris:~]$

Sorry,

It should be

whereis php

Here's the output from a Linux box:

bash-2.05$ whereis php
php: /usr/bin/php /usr/lib/php /usr/local/bin/php /usr/local/lib/php
/usr/local/lib/php.ini /usr/include/php

Ken
Jul 16 '05 #9

"Ken Robinson" <se**********@rbnsn.com> schreef in bericht
news:445d876745776d519e9831619c601b98@TeraNews...
"Ian.H [dS]" <ia*@WINDOZEdigiserv.net> wrote in
news:08********************************@4ax.com:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Whilst lounging around on Sun, 06 Jul 2003 10:56:24 GMT, Ken Robinson
<se**********@rbnsn.com> amazingly managed to produce the following
with their Etch-A-Sketch:
> %which php
> php: Command not found.
> %

That should be

where php
try that...

Ken Robinson

[tk@morris:~]$ where php
bash: where: command not found

[tk@morris:~]$ which php
[tk@morris:~]$

Sorry,

It should be

whereis php

Here's the output from a Linux box:

bash-2.05$ whereis php
php: /usr/bin/php /usr/lib/php /usr/local/bin/php /usr/local/lib/php
/usr/local/lib/php.ini /usr/include/php


I get /usr/ports/lang/php
when I mail to this alias I get:
################################################## ##
----- The following addresses had permanent fatal errors -----
"|/usr/ports/lang/php /www/htdocs/php/do.php"
(reason: 126)
(expanded from: <ph*@oxcamp.com>)

----- Transcript of session follows -----
/usr/ports/lang/php: permission denied
554 5.3.0 unknown mailer error 126
################################################## ##
Does this mean that the mail user does not have permission to read
/usr/ports/lang/php
or that it doesn't have permission to read/write in the /www/htdocs/php/
dir?

Thanks
Jul 16 '05 #10
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Whilst lounging around on Mon, 7 Jul 2003 02:36:58 +0200, "Lukas"
<Lu***@verwijderdit.be> amazingly managed to produce the following
with their Etch-A-Sketch:
I get /usr/ports/lang/php
when I mail to this alias I get:
################################################## ##
----- The following addresses had permanent fatal errors -----
"|/usr/ports/lang/php /www/htdocs/php/do.php"
(reason: 126)
(expanded from: <ph*@oxcamp.com>)

----- Transcript of session follows -----
/usr/ports/lang/php: permission denied
554 5.3.0 unknown mailer error 126
################################################## ##
Does this mean that the mail user does not have permission to read
/usr/ports/lang/php
or that it doesn't have permission to read/write in the
/www/htdocs/php/ dir?

Thanks

Ahh good ol' FreeBSD ports 8)

They're nothing more than a few text files and Makefile(s).

I've got to suspect, that like me, your PHP install is as an Apache
module rather than a binary, hence what you're attempting to do in
PHP isn't gonna happen unless you reinstall PHP as a binary.

Regards,

Ian

-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0

iQA/AwUBPwlLzGfqtj251CDhEQI+IQCbB4r0pLwGEbAMBAZjvTPO7h mqbX4AoNmU
QaDXs4XTCiBZEze8x/Axdkx8
=Kxdw
-----END PGP SIGNATURE-----

--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.
Jul 16 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.