FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » PHP Mailto();
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
PHP Mailto(); [message #182041] Sun, 30 June 2013 23:29 Go to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
Hi,

Win 7, PHP 5.3.5, XAMPP local server, standard Unix remote server:

having a problem with mailto. It's working fine, but ... I can't figure
how to get it to contain all the information I want sent to me. I have
the following:
=========================
$header = "From: abuse(at)hcs-classof64(dot)net";
$to = "abuse(at)hcs-classof64(dot)net";
$subject = "HCS Abuse Form";
$header = "From: $name\r\n";
$header .= "Reply-To: abuse(at)hcs-classof64(dot)net\r\n";
$header .= "Return-Path: abuse(at)hcs-classof64(dot)net\r\n";

mail($to, $subject, $comments , $respond, $header);
========================
And it seems to work fine. But what I'd like to add to the mailto is
the following:
=======================
$browser = $_SERVER['HTTP_USER_AGENT'];
$ipAddress = $_SERVER['REMOTE_ADDR'];
=======================

I've tried the Headers method, simply adding them inlilne. No Good.
I've also tried "and"ing things together like " $comments . $respond "
for instance, but then they all run together and it's difficult to spot
the additional information since there are no line breaks.

For instance, in the mail I receive from the form, Id like to see, each
on their own line with a blank line between is possible:
1. $comments which is the actua verbiage from the visitor,
2, New line,
3. $respond,
4. New line,
4. $ip,
5, New line,
6 $browser
besides the requisite Subject and From lines.
Right now they're being echoed onscreen for my own purposes of
testing, but either way I can't get it all into the form that's sent to
me. I've been playing with this off & on for a week now and guess I need
help!

Can anyone advise me how to accomplish my goal?

TIA,

Twayne`
Re: PHP Mailto(); [message #182047 is a reply to message #182041] Mon, 01 July 2013 05:03 Go to previous messageGo to next message
J.O. Aho is currently offline  J.O. Aho
Messages: 194
Registered: September 2010
Karma: 0
Senior Member
On 01/07/13 01:29, Twayne wrote:
> Hi,
>
> Win 7, PHP 5.3.5, XAMPP local server, standard Unix remote server:
>
> having a problem with mailto. It's working fine, but ... I can't figure
> how to get it to contain all the information I want sent to me. I have
> the following:
> =========================
> $header = "From: abuse(at)hcs-classof64(dot)net";
> $to = "abuse(at)hcs-classof64(dot)net";
> $subject = "HCS Abuse Form";
> $header = "From: $name\r\n";

you forgot the . in front of the =, as now you replace the original From.

> $header .= "Reply-To: abuse(at)hcs-classof64(dot)net\r\n";

No need of this, if you use the original From.

> $header .= "Return-Path: abuse(at)hcs-classof64(dot)net\r\n";
>
> mail($to, $subject, $comments , $respond, $header);

you know that you are sending your headers to the "sendmail command",
see www.php.net/manual/en/function.mail.php

mail($to, $subject, $comments, $header);

> ========================
> And it seems to work fine. But what I'd like to add to the mailto is
> the following:
> =======================
> $browser = $_SERVER['HTTP_USER_AGENT'];
> $ipAddress = $_SERVER['REMOTE_ADDR'];
> =======================
>
> I've tried the Headers method, simply adding them inlilne. No Good.
> I've also tried "and"ing things together like " $comments . $respond "
> for instance, but then they all run together and it's difficult to spot
> the additional information since there are no line breaks.

If you want to add something to the header, then use
"X-something: data\r\n"

Don't use two "From:", use "X-Sender:" for the $name, don't forget to
sanitize the user input or else you will end up with mail header
injections.

$header .= "X-Sender: $name\r\n"; // needs sanitation
$header .= "X-UserAgent: $browser\r\n"; // needs sanitation
$header .= "X-IP: $ipAddress\r\n";

To lessen risk for header injections, include those in the body/message.

$comments .= "Abuse Sender: $name\n"; // needs sanitation
$comments .= "User Agent: $browser\n"; // needs sanitation
$comments .= "IP: $ipAddress\n";

--

//Aho
Re: PHP Mailto(); [message #182048 is a reply to message #182047] Mon, 01 July 2013 09:08 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 01/07/13 06:03, J.O. Aho wrote:
> On 01/07/13 01:29, Twayne wrote:
>> Hi,
>>
>> Win 7, PHP 5.3.5, XAMPP local server, standard Unix remote server:
>>
>> having a problem with mailto. It's working fine, but ... I can't figure
>> how to get it to contain all the information I want sent to me. I have
>> the following:
>> =========================
>> $header = "From: abuse(at)hcs-classof64(dot)net";
>> $to = "abuse(at)hcs-classof64(dot)net";
>> $subject = "HCS Abuse Form";
>> $header = "From: $name\r\n";
>
> you forgot the . in front of the =, as now you replace the original From.
>
>> $header .= "Reply-To: abuse(at)hcs-classof64(dot)net\r\n";
>
> No need of this, if you use the original From.
>
>> $header .= "Return-Path: abuse(at)hcs-classof64(dot)net\r\n";
>>
>> mail($to, $subject, $comments , $respond, $header);
>
> you know that you are sending your headers to the "sendmail command",
> see www.php.net/manual/en/function.mail.php
>
> mail($to, $subject, $comments, $header);
>
>> ========================
>> And it seems to work fine. But what I'd like to add to the mailto is
>> the following:
>> =======================
>> $browser = $_SERVER['HTTP_USER_AGENT'];
>> $ipAddress = $_SERVER['REMOTE_ADDR'];
>> =======================
>>
>> I've tried the Headers method, simply adding them inlilne. No Good.
>> I've also tried "and"ing things together like " $comments . $respond "
>> for instance, but then they all run together and it's difficult to spot
>> the additional information since there are no line breaks.
>
> If you want to add something to the header, then use
> "X-something: data\r\n"
>

Be aware that some combinations of never identified php configurations
and/or mailer MTAS do not seem to like the extra "\r" even though its
strict RFC compliant.
I spent several hours trying various combinations before I settled on a
simple "\n" only, and mail worked as expected.

Where PHP or the MTA was adding in the "\r" automatically I never
discovered, but something was. (linux system)


> Don't use two "From:", use "X-Sender:" for the $name, don't forget to
> sanitize the user input or else you will end up with mail header
> injections.
>
> $header .= "X-Sender: $name\r\n"; // needs sanitation
> $header .= "X-UserAgent: $browser\r\n"; // needs sanitation
> $header .= "X-IP: $ipAddress\r\n";
>
> To lessen risk for header injections, include those in the body/message.
>
> $comments .= "Abuse Sender: $name\n"; // needs sanitation
> $comments .= "User Agent: $browser\n"; // needs sanitation
> $comments .= "IP: $ipAddress\n";
>


--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
Re: PHP Mailto(); [message #182049 is a reply to message #182041] Mon, 01 July 2013 11:50 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
On 6/30/2013 7:29 PM, Twayne wrote:
> Hi,;
> =======================
>
> I've tried the Headers method, simply adding them inlilne. No Good.
> I've also tried "and"ing things together like " $comments .
> $respond " for instance, but then they all run together and it's
> difficult to spot the additional information since there are no
> line breaks.
>
> Twayne`

I do believe that you use \n for a new line in the body of the email.
Re: PHP Mailto(); [message #182050 is a reply to message #182049] Mon, 01 July 2013 11:59 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 01/07/13 12:50, bill wrote:
> On 6/30/2013 7:29 PM, Twayne wrote:
>> Hi,;
>> =======================
>>
>> I've tried the Headers method, simply adding them inlilne. No Good.
>> I've also tried "and"ing things together like " $comments .
>> $respond " for instance, but then they all run together and it's
>> difficult to spot the additional information since there are no
>> line breaks.
>>
>> Twayne`
>
> I do believe that you use \n for a new line in the body of the email.
>
correct. In full spec you should use "\r\n" for headers, but the mail
program in PHP seems to accept \n better.

In the body you can use '\n' without issues.

--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
Re: PHP Mailto(); [message #182051 is a reply to message #182050] Mon, 01 July 2013 12:47 Go to previous messageGo to next message
J.O. Aho is currently offline  J.O. Aho
Messages: 194
Registered: September 2010
Karma: 0
Senior Member
On Mon, 1 Jul 2013, The Natural Philosopher wrote:
> On 01/07/13 12:50, bill wrote:
>> On 6/30/2013 7:29 PM, Twayne wrote:
>>>
>>> I've tried the Headers method, simply adding them inlilne. No Good.
>>> I've also tried "and"ing things together like " $comments .
>>> $respond " for instance, but then they all run together and it's
>>> difficult to spot the additional information since there are no
>>> line breaks.
>>
>> I do believe that you use \n for a new line in the body of the email.
>>
> correct. In full spec you should use "\r\n" for headers, but the mail program
> in PHP seems to accept \n better.

If I remember this correct, it's different in ms-windows and Linux/Unix with
the "best" option in the header \n or \r\n, think the later is needed in
ms-windows. There was some issues PHP 5.2 -> PHP 5.3 where using \r\n on
Linux/Unix broke and people started to change to just use \n.
To make it more portable, you could use PHP_EOL instead, then it should work
fine in which ever environment without need of code change.



> In the body you can use '\n' without issues.

Usually \n works in body like a charm, but I think some old clients may get
some display issues if you use an ms-dos charset in the mail header for the mail,
but I think that is quite rare and shouldn't need to be tought of.

--
//Aho
Re: PHP Mailto(); [message #182052 is a reply to message #182051] Mon, 01 July 2013 13:09 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 01/07/13 13:47, J.O. Aho wrote:
> On Mon, 1 Jul 2013, The Natural Philosopher wrote:
>> On 01/07/13 12:50, bill wrote:
>>> On 6/30/2013 7:29 PM, Twayne wrote:
>>>> > I've tried the Headers method, simply adding them inlilne. No
>>> Good.
>>>> I've also tried "and"ing things together like " $comments .
>>>> $respond " for instance, but then they all run together and it's
>>>> difficult to spot the additional information since there are no
>>>> line breaks.
>>>
>>> I do believe that you use \n for a new line in the body of the email.
>>>
>> correct. In full spec you should use "\r\n" for headers, but the mail
>> program in PHP seems to accept \n better.
>
> If I remember this correct, it's different in ms-windows and
> Linux/Unix with the "best" option in the header \n or \r\n, think the
> later is needed in ms-windows. There was some issues PHP 5.2 -> PHP
> 5.3 where using \r\n on Linux/Unix broke and people started to change
> to just use \n.
> To make it more portable, you could use PHP_EOL instead, then it
> should work fine in which ever environment without need of code change.
>
>
That is a thought. I'd forgotten PHP_EOL


>
>> In the body you can use '\n' without issues.
>
> Usually \n works in body like a charm, but I think some old clients
> may get some display issues if you use an ms-dos charset in the mail
> header for the mail, but I think that is quite rare and shouldn't need
> to be tought of.
>


--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
Re: PHP Mailto(); [message #182053 is a reply to message #182049] Mon, 01 July 2013 14:10 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
On 2013-07-01 7:50 AM, bill wrote:
> On 6/30/2013 7:29 PM, Twayne wrote:
>> Hi,;
>> =======================
>>
>> I've tried the Headers method, simply adding them inlilne. No Good.
>> I've also tried "and"ing things together like " $comments .
>> $respond " for instance, but then they all run together and it's
>> difficult to spot the additional information since there are no
>> line breaks.
>>
>> Twayne`
>
> I do believe that you use \n for a new line in the body of the email.
>

If anyone is interested, there seems to be a pretty good Q&A for EOL at:

http://stackoverflow.com/questions/128560/when-do-i-use-the-php-constant-ph p-eol

Almost all the pros & cons are sensible, thought-out comments.

Twayne`
Re: PHP Mailto(); [message #182054 is a reply to message #182047] Mon, 01 July 2013 14:23 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
On 2013-07-01 1:03 AM, J.O. Aho wrote:
> On 01/07/13 01:29, Twayne wrote:
>> Hi,
>>
>> Win 7, PHP 5.3.5, XAMPP local server, standard Unix remote server:
>>
>> having a problem with mailto. It's working fine, but ... I can't figure
>> how to get it to contain all the information I want sent to me. I have

>> =========================

....
>
> If you want to add something to the header, then use
> "X-something: data\r\n"
>
> Don't use two "From:", use "X-Sender:" for the $name, don't forget to
> sanitize the user input or else you will end up with mail header
> injections.
>
> $header .= "X-Sender: $name\r\n"; // needs sanitation
> $header .= "X-UserAgent: $browser\r\n"; // needs sanitation
> $header .= "X-IP: $ipAddress\r\n";
>
> To lessen risk for header injections, include those in the body/message.
>
> $comments .= "Abuse Sender: $name\n"; // needs sanitation
> $comments .= "User Agent: $browser\n"; // needs sanitation
> $comments .= "IP: $ipAddress\n";
>

That's a keeper! Thanks much for sharing.

X-sender I hadn't thought of and I'll try it. As for \r\n vs \n, I'd
forgotten all about because I normally use (not successfully in this
case) <br />.

I've also been reading about PHP EOL; any opinions on that? Other than
knowing when to use it, it sounds like it might be handy if it's not
deprecated; haven't looked it up yet.

Thanks much,

Twayne`
Re: PHP Mailto(); [message #182055 is a reply to message #182048] Mon, 01 July 2013 14:33 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
On 2013-07-01 5:08 AM, The Natural Philosopher wrote:
> On 01/07/13 06:03, J.O. Aho wrote:
>> On 01/07/13 01:29, Twayne wrote:
>>> Hi,
>>>
>>> Win 7, PHP 5.3.5, XAMPP local server, standard Unix remote server:
>>>
>>> having a problem with mailto. It's working fine, but ... I can't figure
>>> how to get it to contain all the information I want sent to me. I have
>>> the following:
>>> =========================
>>> $header = "From: abuse(at)hcs-classof64(dot)net";
>>> $to = "abuse(at)hcs-classof64(dot)net";
>>> $subject = "HCS Abuse Form";
>>> $header = "From: $name\r\n";
>>
>> you forgot the . in front of the =, as now you replace the original From.
>>
>>> $header .= "Reply-To: abuse(at)hcs-classof64(dot)net\r\n";
>>
>> No need of this, if you use the original From.
>>
>>> $header .= "Return-Path: abuse(at)hcs-classof64(dot)net\r\n";
>>>
>>> mail($to, $subject, $comments , $respond, $header);
>>
>> you know that you are sending your headers to the "sendmail command",
>> see www.php.net/manual/en/function.mail.php
>>
>> mail($to, $subject, $comments, $header);
>>
>>> ========================
>>> And it seems to work fine. But what I'd like to add to the mailto is
>>> the following:
>>> =======================
>>> $browser = $_SERVER['HTTP_USER_AGENT'];
>>> $ipAddress = $_SERVER['REMOTE_ADDR'];
>>> =======================
>>>
>>> I've tried the Headers method, simply adding them inlilne. No Good.
>>> I've also tried "and"ing things together like " $comments . $respond "
>>> for instance, but then they all run together and it's difficult to spot
>>> the additional information since there are no line breaks.
>>
>> If you want to add something to the header, then use
>> "X-something: data\r\n"
>>
>
> Be aware that some combinations of never identified php configurations
> and/or mailer MTAS do not seem to like the extra "\r" even though its
> strict RFC compliant.
> I spent several hours trying various combinations before I settled on a
> simple "\n" only, and mail worked as expected.

Well at least I know what to experiment with anyway<grin. Thanks.

>
> Where PHP or the MTA was adding in the "\r" automatically I never
> discovered, but something was. (linux system)

I had that situation too; removing any newline of any sort from the
particular statement corrected it.

>
>
>> Don't use two "From:", use "X-Sender:" for the $name, don't forget to
>> sanitize the user input or else you will end up with mail header
>> injections.
>>
>> $header .= "X-Sender: $name\r\n"; // needs sanitation
>> $header .= "X-UserAgent: $browser\r\n"; // needs sanitation
>> $header .= "X-IP: $ipAddress\r\n";
>>
>> To lessen risk for header injections, include those in the body/message.
>>
>> $comments .= "Abuse Sender: $name\n"; // needs sanitation
>> $comments .= "User Agent: $browser\n"; // needs sanitation
>> $comments .= "IP: $ipAddress\n";
>>
>
>

Thanks Nat,

Twayne`
Re: PHP Mailto(); [message #182056 is a reply to message #182054] Mon, 01 July 2013 15:28 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article <kqs3dn$2s7$1(at)speranza(dot)aioe(dot)org>,
Twayne <nobody(at)spamcop(dot)net> wrote:

> On 2013-07-01 1:03 AM, J.O. Aho wrote:
>> On 01/07/13 01:29, Twayne wrote:
>>> Hi,
>>>
>>> Win 7, PHP 5.3.5, XAMPP local server, standard Unix remote server:
>>>
>>> having a problem with mailto. It's working fine, but ... I can't figure
>>> how to get it to contain all the information I want sent to me. I have
>
>>> =========================
>
> ...
>>
>> If you want to add something to the header, then use
>> "X-something: data\r\n"
>>
>> Don't use two "From:", use "X-Sender:" for the $name, don't forget to
>> sanitize the user input or else you will end up with mail header
>> injections.
>>
>> $header .= "X-Sender: $name\r\n"; // needs sanitation
>> $header .= "X-UserAgent: $browser\r\n"; // needs sanitation
>> $header .= "X-IP: $ipAddress\r\n";
>>
>> To lessen risk for header injections, include those in the body/message.
>>
>> $comments .= "Abuse Sender: $name\n"; // needs sanitation
>> $comments .= "User Agent: $browser\n"; // needs sanitation
>> $comments .= "IP: $ipAddress\n";
>>
>
> That's a keeper! Thanks much for sharing.
>
> X-sender I hadn't thought of and I'll try it. As for \r\n vs \n, I'd
> forgotten all about because I normally use (not successfully in this
> case) <br />.
>
> I've also been reading about PHP EOL; any opinions on that? Other than
> knowing when to use it, it sounds like it might be handy if it's not
> deprecated; haven't looked it up yet.

Since the standards specify CRLF I do this:

$lf = chr (10);
$cr = chr (13);
$nl = $cr . $lf;

and use $nl throughout.

You might also want to snoop on your traffic to see what gets sent. I
use PacketPeeper for this.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: PHP Mailto(); [message #182057 is a reply to message #182053] Mon, 01 July 2013 15:34 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article <kqs2ks$ln$1(at)speranza(dot)aioe(dot)org>, Twayne <nobody(at)spamcop(dot)net>
wrote:

> On 2013-07-01 7:50 AM, bill wrote:
>> On 6/30/2013 7:29 PM, Twayne wrote:
>>> Hi,;

>>> I've tried the Headers method, simply adding them inlilne. No Good.
>>> I've also tried "and"ing things together like " $comments .
>>> $respond " for instance, but then they all run together and it's
>>> difficult to spot the additional information since there are no
>>> line breaks.

>> I do believe that you use \n for a new line in the body of the email.
>>
>
> If anyone is interested, there seems to be a pretty good Q&A for EOL at:
>
> http://stackoverflow.com/questions/128560/when-do-i-use-the-php-constant-ph p-e
> ol
>
> Almost all the pros & cons are sensible, thought-out comments.

How about reading the RFCs to see what you are *actually* supposed to
do. Such as RFC 2821 section 2.3.7.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: PHP Mailto(); [message #182058 is a reply to message #182057] Mon, 01 July 2013 15:58 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 01/07/13 16:34, Tim Streater wrote:
> In article <kqs2ks$ln$1(at)speranza(dot)aioe(dot)org>, Twayne
> <nobody(at)spamcop(dot)net> wrote:
>
>> On 2013-07-01 7:50 AM, bill wrote:
>>> On 6/30/2013 7:29 PM, Twayne wrote:
>>>> Hi,;
>
>>>> I've tried the Headers method, simply adding them inlilne. No Good.
>>>> I've also tried "and"ing things together like " $comments .
>>>> $respond " for instance, but then they all run together and it's
>>>> difficult to spot the additional information since there are no
>>>> line breaks.
>
>>> I do believe that you use \n for a new line in the body of the email.
>>>
>>
>> If anyone is interested, there seems to be a pretty good Q&A for EOL at:
>>
>> http://stackoverflow.com/questions/128560/when-do-i-use-the-php-constant-ph p-e
>>
>> ol
>>
>> Almost all the pros & cons are sensible, thought-out comments.
>
> How about reading the RFCs to see what you are *actually* supposed to
> do. Such as RFC 2821 section 2.3.7.
>
The problem tim, is that in my case, that is exactly what I DID do, but
it came out WRONG
I spent a merry morning trying everything, before concluding that
somewhere between a PHP statement and a mail recieved at the far end,
something was tampering with new lines in the headers.

I couldn't actually easily check the sendmail (or analogue thereof)
dialogue , but I was able to see te 'wrongness' in spooled mail sent to
unreachable targets. That hung around long enough to disassemble.

My guess is that PHP tries to be smart. Sometimes too smart for its own
good.

--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
Re: PHP Mailto(); [message #182059 is a reply to message #182057] Mon, 01 July 2013 17:05 Go to previous messageGo to next message
J.O. Aho is currently offline  J.O. Aho
Messages: 194
Registered: September 2010
Karma: 0
Senior Member
On 01/07/13 17:34, Tim Streater wrote:
> In article <kqs2ks$ln$1(at)speranza(dot)aioe(dot)org>, Twayne <nobody(at)spamcop(dot)net>
> wrote:
>
>> On 2013-07-01 7:50 AM, bill wrote:
>>> On 6/30/2013 7:29 PM, Twayne wrote:
>>>> Hi,;
>
>>>> I've tried the Headers method, simply adding them inlilne. No Good.
>>>> I've also tried "and"ing things together like " $comments .
>>>> $respond " for instance, but then they all run together and it's
>>>> difficult to spot the additional information since there are no
>>>> line breaks.
>
>>> I do believe that you use \n for a new line in the body of the email.
>>>
>>
>> If anyone is interested, there seems to be a pretty good Q&A for EOL at:
>>
>> http://stackoverflow.com/questions/128560/when-do-i-use-the-php-constant-ph p-e
>>
>> ol
>>
>> Almost all the pros & cons are sensible, thought-out comments.
>
> How about reading the RFCs to see what you are *actually* supposed to
> do. Such as RFC 2821 section 2.3.7.

RFC is one thing and PHP uses some replacing of carriage return and new
lines to make the data sent to the mail sever correct, which makes it
better to have \r\n on ms-windows, \r on OSX/MacOS and \n on Linux/Unix.


--

//Aho
Re: PHP Mailto(); [message #182060 is a reply to message #182059] Mon, 01 July 2013 17:21 Go to previous messageGo to next message
Christoph Michael Bec is currently offline  Christoph Michael Bec
Messages: 207
Registered: June 2013
Karma: 0
Senior Member
J.O. Aho wrote:
> RFC is one thing and PHP uses some replacing of carriage return and new
> lines to make the data sent to the mail sever correct, which makes it
> better to have \r\n on ms-windows, \r on OSX/MacOS and \n on Linux/Unix.

According to the documentation on php.net[1] it is not PHP that replaces
the line breaks, but some MTAs:

| If messages are not received, try using a LF (\n) only. Some Unix
| mail transfer agents (most notably » qmail) replace LF by CRLF
| automatically (which leads to doubling CR if CRLF is used). This
| should be a last resort, as it does not comply with » RFC 2822.

[1] <http://php.net/manual/en/function.mail.php>

--
Christoph M. Becker
Re: PHP Mailto(); [message #182061 is a reply to message #182058] Mon, 01 July 2013 17:24 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article <kqs8vr$38l$1(at)news(dot)albasani(dot)net>,
The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:

> On 01/07/13 16:34, Tim Streater wrote:
>> In article <kqs2ks$ln$1(at)speranza(dot)aioe(dot)org>, Twayne
>> <nobody(at)spamcop(dot)net> wrote:
>>
>>> On 2013-07-01 7:50 AM, bill wrote:
>>>> On 6/30/2013 7:29 PM, Twayne wrote:
>>>> > Hi,;
>>
>>>> > I've tried the Headers method, simply adding them inlilne. No Good.
>>>> > I've also tried "and"ing things together like " $comments .
>>>> > $respond " for instance, but then they all run together and it's
>>>> > difficult to spot the additional information since there are no
>>>> > line breaks.
>>
>>>> I do believe that you use \n for a new line in the body of the email.
>>>>
>>>
>>> If anyone is interested, there seems to be a pretty good Q&A for EOL at:
>>>
>>> http://stackoverflow.com/questions/128560/when-do-i-use-the-php-constant-ph
>>> p-e
>>>
>>> ol
>>>
>>> Almost all the pros & cons are sensible, thought-out comments.
>>
>> How about reading the RFCs to see what you are *actually* supposed to
>> do. Such as RFC 2821 section 2.3.7.
>>
> The problem tim, is that in my case, that is exactly what I DID do, but
> it came out WRONG
> I spent a merry morning trying everything, before concluding that
> somewhere between a PHP statement and a mail recieved at the far end,
> something was tampering with new lines in the headers.
>
> I couldn't actually easily check the sendmail (or analogue thereof)
> dialogue , but I was able to see te 'wrongness' in spooled mail sent to
> unreachable targets. That hung around long enough to disassemble.
>
> My guess is that PHP tries to be smart. Sometimes too smart for its own
> good.

Thass one reason I rolled my own. Besides which it was fun.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: PHP Mailto(); [message #182062 is a reply to message #182060] Mon, 01 July 2013 17:30 Go to previous messageGo to next message
J.O. Aho is currently offline  J.O. Aho
Messages: 194
Registered: September 2010
Karma: 0
Senior Member
On 01/07/13 19:21, Christoph Michael Becker wrote:
> J.O. Aho wrote:
>> RFC is one thing and PHP uses some replacing of carriage return and new
>> lines to make the data sent to the mail sever correct, which makes it
>> better to have \r\n on ms-windows, \r on OSX/MacOS and \n on Linux/Unix.
>
> According to the documentation on php.net[1] it is not PHP that replaces
> the line breaks, but some MTAs:

Maybe some does, but there is also this nice comment:

/* This pattern converts all single occurences of \n (Unix)
* withour a leading \r to \r\n and all occurences of \r (Mac)
* without a trailing \n to \r\n
* Thx to Nibbler from ircnet/#linuxger
*/


--

//Aho
Re: PHP Mailto(); [message #182063 is a reply to message #182061] Mon, 01 July 2013 17:47 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 01/07/13 18:24, Tim Streater wrote:
> In article <kqs8vr$38l$1(at)news(dot)albasani(dot)net>,
> The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:
>
>> On 01/07/13 16:34, Tim Streater wrote:
>>> In article <kqs2ks$ln$1(at)speranza(dot)aioe(dot)org>, Twayne >
>> <nobody(at)spamcop(dot)net> wrote:
>>>
>>>> On 2013-07-01 7:50 AM, bill wrote:
>>>> > On 6/30/2013 7:29 PM, Twayne wrote:
>>>> >> Hi,;
>>>
>>>> >> I've tried the Headers method, simply adding them inlilne. No
>> Good.
>>>> >> I've also tried "and"ing things together like " $comments .
>>>> >> $respond " for instance, but then they all run together and it's
>>>> >> difficult to spot the additional information since there are no
>>>> >> line breaks.
>>>
>>>> > I do believe that you use \n for a new line in the body of the
>> email.
>>>> >
>>>>
>>>> If anyone is interested, there seems to be a pretty good Q&A for
>> EOL at:
>>>>
>>>>
>> http://stackoverflow.com/questions/128560/when-do-i-use-the-php-constant-ph
>>>> p-e >>
>>>> ol
>>>>
>>>> Almost all the pros & cons are sensible, thought-out comments.
>>>
>>> How about reading the RFCs to see what you are *actually* supposed
>> to > do. Such as RFC 2821 section 2.3.7.
>>>
>> The problem tim, is that in my case, that is exactly what I DID do,
>> but it came out WRONG
>> I spent a merry morning trying everything, before concluding that
>> somewhere between a PHP statement and a mail recieved at the far end,
>> something was tampering with new lines in the headers.
>>
>> I couldn't actually easily check the sendmail (or analogue thereof)
>> dialogue , but I was able to see te 'wrongness' in spooled mail sent
>> to unreachable targets. That hung around long enough to disassemble.
>>
>> My guess is that PHP tries to be smart. Sometimes too smart for its
>> own good.
>
> Thass one reason I rolled my own. Besides which it was fun.
>
yerrss. I did a simple smtp client in C, but not in PHP.



--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
Re: PHP Mailto(); [message #182064 is a reply to message #182063] Mon, 01 July 2013 19:43 Go to previous message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article <kqsfcb$h4b$2(at)news(dot)albasani(dot)net>,
The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:

> On 01/07/13 18:24, Tim Streater wrote:
>> In article <kqs8vr$38l$1(at)news(dot)albasani(dot)net>,
>> The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:
>>
>>> On 01/07/13 16:34, Tim Streater wrote:
>>>> In article <kqs2ks$ln$1(at)speranza(dot)aioe(dot)org>, Twayne >
>>> <nobody(at)spamcop(dot)net> wrote:
>>>>
>>>> > On 2013-07-01 7:50 AM, bill wrote:
>>>> > > On 6/30/2013 7:29 PM, Twayne wrote:
>>>> > >> Hi,;
>>>>
>>>> > >> I've tried the Headers method, simply adding them inlilne. No
>>> Good.
>>>> > >> I've also tried "and"ing things together like " $comments .
>>>> > >> $respond " for instance, but then they all run together and it's
>>>> > >> difficult to spot the additional information since there are no
>>>> > >> line breaks.
>>>>
>>>> > > I do believe that you use \n for a new line in the body of the
>>> email.
>>>> > >
>>>> >
>>>> > If anyone is interested, there seems to be a pretty good Q&A for
>>> EOL at:
>>>> >
>>>> >
>>> http://stackoverflow.com/questions/128560/when-do-i-use-the-php-constant-ph
>>>> > p-e >>
>>>> > ol
>>>> >
>>>> > Almost all the pros & cons are sensible, thought-out comments.
>>>>
>>>> How about reading the RFCs to see what you are *actually* supposed
>>> to > do. Such as RFC 2821 section 2.3.7.
>>>>
>>> The problem tim, is that in my case, that is exactly what I DID do,
>>> but it came out WRONG
>>> I spent a merry morning trying everything, before concluding that
>>> somewhere between a PHP statement and a mail recieved at the far end,
>>> something was tampering with new lines in the headers.
>>>
>>> I couldn't actually easily check the sendmail (or analogue thereof)
>>> dialogue , but I was able to see te 'wrongness' in spooled mail sent
>>> to unreachable targets. That hung around long enough to disassemble.
>>>
>>> My guess is that PHP tries to be smart. Sometimes too smart for its
>>> own good.
>>
>> Thass one reason I rolled my own. Besides which it was fun.
>>
> yerrss. I did a simple smtp client in C, but not in PHP.

Mine's a full-blown email client.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: DIY finger tip typin - pace and code, (PHP open source)
Next Topic: tracking IP's
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Dec 03 18:22:51 GMT 2024

Total time taken to generate the page: 0.02808 seconds