Re: Re: Problem sending mail
| From: | Zoran Lorkovic | Date: | Tue, 31 Aug 2004 08:40:00 +0000 |
| Subject: | Re: Re: Problem sending mail | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-195253@lists.php.net to get a copy of this message | ||
> Zoran Lorkovic wrote:
>
> > $file = file_get_contents("text.inc");
> > $start = "[start]";
> > $end = "[/end]";
> > $pos_start = strpos ($file, $start);
> > $pos_end = strpos ($file, $end);
> > $data = substr ($file, $pos_start, $pos_end);
> > mail ("myemail@domain.com", "My Subject", $data);
> >
> >
> > This code works when I call it from browser, but when I call it from
command line, $data is not put into mail
> > (mail is send but it is empty, without any data in body).
> >
> that would depend from which place you run the script.
> file_get_contents("text.inc") will be looked for in:
> 1. the current working directory
> 2. the included dirs
>
> So, if you're running the script like:
> [user@server /]# cd /
> [user@server /]# php -q /var/www/html/scripts/mail.php
> then you're actually working in /, so it's looking for "text.inc" in:
> /text.inc and in all include-paths.
Yeah! Of course. This was the problem.
Script and text file were in 'mydir/public_html' but I call script from
'mydir' so I script looks for text file in 'mydir' because of $file =
file_get_contents("text.inc");
For the quick test I've changed this to:
$file = file_get_contents("public_html/text.inc");
and now it's working. Thanks a lot!
Regards.
Zoran