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

Home » Imported messages » comp.lang.php » Placing an URL in email
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Placing an URL in email [message #171740] Thu, 20 January 2011 02:12 Go to next message
jwcarlton is currently offline  jwcarlton
Messages: 76
Registered: December 2010
Karma: 0
Member
I'm sending an HTML email through PHP, and the email includes a
website link. Like so:

<a href="http://www.example.com/whatever/?action=something&id=4300">
http://www.example.com/whatever/?action=something&id=4300
</a>

The problem I'm having is that the link is showing up in the email
like this:

http://www.example.com/whatever/?action=something&id300

Notice the last variable is "id300" instead of "id=4300".

I've tried using urlencode(), and while this does fix the actual link,
the displayed URL has the coded symbols. What function should I be
using to show the website link correctly?
Re: Placing an URL in email [message #171747 is a reply to message #171740] Thu, 20 January 2011 07:09 Go to previous messageGo to next message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma: 0
Senior Member
.oO(jwcarlton)

> I'm sending an HTML email through PHP, and the email includes a
> website link. Like so:
>
> <a href="http://www.example.com/whatever/?action=something&id=4300">
> http://www.example.com/whatever/?action=something&id=4300
> </a>
>
> The problem I'm having is that the link is showing up in the email
> like this:
>
> http://www.example.com/whatever/?action=something&id300
>
> Notice the last variable is "id300" instead of "id=4300".

This must be a bug in your code.

Micha
Re: Placing an URL in email [message #171748 is a reply to message #171747] Thu, 20 January 2011 08:07 Go to previous messageGo to next message
jwcarlton is currently offline  jwcarlton
Messages: 76
Registered: December 2010
Karma: 0
Member
On Jan 20, 2:09 am, Michael Fesser <neti...@gmx.de> wrote:
> .oO(jwcarlton)
>
>> I'm sending an HTML email through PHP, and the email includes a
>> website link. Like so:
>
>> <a href="http://www.example.com/whatever/?action=something&id=4300">
>> http://www.example.com/whatever/?action=something&id=4300
>> </a>
>
>> The problem I'm having is that the link is showing up in the email
>> like this:
>
>> http://www.example.com/whatever/?action=something&id300
>
>> Notice the last variable is "id300" instead of "id=4300".
>
> This must be a bug in your code.
>
> Micha

Here's what I'm using:

$to = "sales(at)example(dot)com";
$subject = "Test";

$headers = "From: $user<$user(at)example(dot)com>\n";
$headers .= "build-To: <$user(at)example(dot)com>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/related; ";
$headers .= "type=\"multipart/alternative\"; ";
$headers .= "boundary=\"----=MIME_BOUNDRY_main_message\"\n";
$headers .= "X-Sender: $user<$user(at)example(dot)com>\n";
$headers .= "X-Mailer: PHP4\n";
$headers .= "X-Priority: 1\n"; //1 = Urgent, 3 = Normal
$headers .= "Return-Path: <$user(at)example(dot)com>\n";
$headers .= "This is a multi-part message in MIME format.\n";
$headers .= "------=MIME_BOUNDRY_main_message \n";
$headers .= "Content-Type: multipart/alternative; ";
$headers .= "boundary=\"----=MIME_BOUNDRY_message_parts\"\n";

$message = "------=MIME_BOUNDRY_message_parts\n";
$message .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
$message .= "Content-Transfer-Encoding: quoted-printable\n";
$message .= "\n";

$message .= "<a href='http://www.example.com/whatever/?
action=something&id=4300'>\n";
$message .= "http://www.example.com/whatever/?
action=something&id=4300\n";
$message .= "</a>";

$message .= "\n";
$message .= "------=MIME_BOUNDRY_message_parts--\n";
$message .= "\n";

mail($to, $subject, $message, $headers);
Re: Placing an URL in email [message #171884 is a reply to message #171748] Thu, 20 January 2011 08:23 Go to previous messageGo to next message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma: 0
Senior Member
El 20/01/2011 9:07, jwcarlton escribió/wrote:
> Here's what I'm using:
[...]
> $message = "------=MIME_BOUNDRY_message_parts\n";
> $message .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
> $message .= "Content-Transfer-Encoding: quoted-printable\n";
^^^^^^^^^^^^^^^^
> $message .= "\n";
>
> $message .= "<a href='http://www.example.com/whatever/?
> action=something&id=4300'>\n";
> $message .= "http://www.example.com/whatever/?
> action=something&id=4300\n";
> $message .= "</a>";
>
> $message .= "\n";
> $message .= "------=MIME_BOUNDRY_message_parts--\n";
> $message .= "\n";
>
> mail($to, $subject, $message, $headers);

You declare the encoding as quoted printable but you never encode it.
I'd expect to see quoted_printable_encode() somewhere.

Also, in HTML you must use &amp; to insert literal ampersands. Have a
look at htmlspecialchars().



--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
Re: Placing an URL in email [message #171896 is a reply to message #171740] Thu, 20 January 2011 13:36 Go to previous messageGo to next message
Peter H. Coffin is currently offline  Peter H. Coffin
Messages: 245
Registered: September 2010
Karma: 0
Senior Member
On Wed, 19 Jan 2011 18:12:16 -0800 (PST), jwcarlton wrote:
> I'm sending an HTML email through PHP, and the email includes a
> website link. Like so:
>
> <a href="http://www.example.com/whatever/?action=something&id=4300">
> http://www.example.com/whatever/?action=something&id=4300
> </a>
>
> The problem I'm having is that the link is showing up in the email
> like this:
>
> http://www.example.com/whatever/?action=something&id300
>
> Notice the last variable is "id300" instead of "id=4300".
>
> I've tried using urlencode(), and while this does fix the actual link,
> the displayed URL has the coded symbols. What function should I be
> using to show the website link correctly?

Turn off quoted-printable in your MIME encoding. If you're sending HTML,
you don't need it anyway. Proper HTML is already 7-bit clean.

--
67. No matter how many shorts we have in the system, my guards will be
instructed to treat every surveillance camera malfunction as a
full-scale emergency.
--Peter Anspach's list of things to do as an Evil Overlord
Re: Placing an URL in email [message #171899 is a reply to message #171896] Thu, 20 January 2011 15:45 Go to previous messageGo to next message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma: 0
Senior Member
El 20/01/2011 14:36, Peter H. Coffin escribió/wrote:
> Turn off quoted-printable in your MIME encoding. If you're sending HTML,
> you don't need it anyway. Proper HTML is already 7-bit clean.

Where did you get such idea? Even the W3C uses UTF-8 in their own site.

http://www.w3.org/


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
Re: Placing an URL in email [message #171909 is a reply to message #171899] Thu, 20 January 2011 20:48 Go to previous messageGo to next message
Peter H. Coffin is currently offline  Peter H. Coffin
Messages: 245
Registered: September 2010
Karma: 0
Senior Member
On Thu, 20 Jan 2011 16:45:58 +0100, ?lvaro G. Vicario wrote:
> El 20/01/2011 14:36, Peter H. Coffin escribi?/wrote:
>> Turn off quoted-printable in your MIME encoding. If you're sending HTML,
>> you don't need it anyway. Proper HTML is already 7-bit clean.
>
> Where did you get such idea? Even the W3C uses UTF-8 in their own site.
>
> http://www.w3.org/

Okay "can be 7-bit clean". Happier?

The point being that there are more than enough ampersand entitites that
there's no reason that anyone would need to bother with hex-encoding
anything to enable safe SMTP transit in the message body. Since
quoted-printable is Causing A Problem, ditching that is the easy
solution to the problem. Rewriting an application in order to make
different URLs seems like far more work.

--
We're the technical experts. We were hired so that management could
ignore our recommendations and tell us how to do our jobs.
-- Mike Andrews
Re: Placing an URL in email [message #171947 is a reply to message #171909] Sat, 22 January 2011 11:36 Go to previous messageGo to next message
Tuz Mwaura is currently offline  Tuz Mwaura
Messages: 1
Registered: January 2011
Karma: 0
Junior Member
On Jan 20, 11:48 pm, "Peter H. Coffin" <hell...@ninehells.com> wrote:
> On Thu, 20 Jan 2011 16:45:58 +0100, ?lvaro G. Vicario wrote:
>> El 20/01/2011 14:36, Peter H. Coffin escribi?/wrote:
>>> Turn off quoted-printable in your MIME encoding. If you're sending HTML,
>>> you don't need it anyway. Proper HTML is already 7-bit clean.
>
>> Where did you get such idea? Even the W3C uses UTF-8 in their own site.
>
>> http://www.w3.org/
>
> Okay "can be 7-bit clean". Happier?
>
> The point being that there are more than enough ampersand entitites that
> there's no reason that anyone would need to bother with hex-encoding
> anything to enable safe SMTP transit in the message body. Since
> quoted-printable is Causing A Problem, ditching that is the easy
> solution to the problem. Rewriting an application in order to make
> different URLs seems like far more work.
>
> --
> We're the technical experts.  We were hired so that management could
> ignore our recommendations and tell us how to do our jobs.
>               -- Mike Andrews

Try this line in your code
<a href="http://www.example.com/whatever/?action=something&id=
\"4300\" ">
http://www.example.com/whatever/?action=something &id=\"4300\" </a>
Re: Placing an URL in email [message #171948 is a reply to message #171947] Sat, 22 January 2011 13:22 Go to previous message
Felix Saphir is currently offline  Felix Saphir
Messages: 8
Registered: December 2010
Karma: 0
Junior Member
Tuz Mwaura <tuzmwaura(at)gmail(dot)com> wrote:
>
> Try this line in your code
> <a href="http://www.example.com/whatever/?action=something&id=
> \"4300\" ">
> http://www.example.com/whatever/?action=something &id=\"4300\"
> </a>

Try learning HTML ...

Felix
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: hack
Next Topic: Using a heredoc in PHP as in Perl
Goto Forum:
  

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

Current Time: Fri Nov 22 20:18:16 GMT 2024

Total time taken to generate the page: 0.02595 seconds