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
Return to the default flat view Create a new topic Submit Reply
Re: PHP Mailto(); [message #182048 is a reply to message #182047] Mon, 01 July 2013 09:08 Go to previous messageGo to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma:
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.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
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: Thu Jan 30 22:59:11 GMT 2025

Total time taken to generate the page: 0.04063 seconds