Re: Trouble with sending e-mail from simple php script [message #176515 is a reply to message #176501] |
Sun, 08 January 2012 22:02 |
The Natural Philosoph
Messages: 993 Registered: September 2010
Karma:
|
Senior Member |
|
|
C wrote:
> On Jan 8, 4:34 pm, The Natural Philosopher <t...@invalid.invalid>
> wrote:
>> M. Strobel wrote:
>>> Am 08.01.2012 10:20, schrieb C:
>>>> Even if the message were rejected, I would still see something in that
>>>> frame, but I get only a blank frame. Client machine rejecting the
>>>> message should not even be noticed by this PHP script, or would it?
>>> You have to learn how to find and read the log files. Your script
>>> will not show errors if it dies.
>>> On Linux log files are only readable by root.
>>> /Str.
>> Probably the most common error when using mail() from within php on a
>> shared host is to fail to use the -f function to pass a valid sender
>> address to sendmail (or its analogue). Without that, the 'true' sender
>> is likely to be 'your-login-n...@hosting-omain.com' which will fail most
>> rudimentary validation and simply reject the mail.
>>
>> I ALWAYS use the -f to set the sender to something like
>> 'webmas...@myvirtualdomson.com' and set up that virtual domain so that
>> webmaster is a valid known target for emails.
>>
>> e.g.
>>
>> mail($to, $subject, $body, $headers, "-f webmas...@mydomain.com");
>>
>> is far more likely to get through anti-relay security in the hosts
>> mailer system.
>>
>> Start by testing the host mailer with the above line, so
>>
>> mail("m...@validmail.com","test message", "From:
>> anot...@validmail.com\r\n", -f "webmas...@mydomain.com");
>>
>> is where you should start.
>
> I did that and got an error: Parse error: syntax error, unexpected
> T_CONSTANT_ENCAPSED_STRING
>
Then you typed it wrong
>> If that fails to make it then you need to talk to the hosting company.
>
> I wrote the following test.php, uploaded it and tried it.
>
> <?php
>
> mail("aaaa....@gmail.com","test message", "From:
> postmaster(at)example(dot)org\r\n", -f "postmaster(at)example(dot)org");
>
> ?>
did it work or not...?
>
> My earlier code works well on two other sites of mine which are
> sitting on other shared servers.
So the problem is in the setting of this shared servers mail, which is
what I said..unless you have some other versions of php running.
|
|
|