Problems sending HREF link in body of email

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lunny
Forum Newbie
Posts: 13
Joined: Mon Feb 19, 2007 8:33 am

Problems sending HREF link in body of email

Post by lunny »

We want to send an email containing a HREF link but having problems with escape characters or whatever.

So in the body of the mail we have

$bodyPT2 = "<a href =".$fullUrl.">link </a>";

where fullURL is a user inputted URL but when we open the mail we get

<a href =http://something/boom249.php>link </a>

instead of just showing

"link"

Any Help ? : (
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

The escape character is the backslash (\)

You could do
$bodyPT2 = "<a href =\"".$fullUrl."\">link </a>";
or
$bodyPT2 = '<a href ="'.$fullUrl.'">link </a>';
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

You would need to create a MIME encoded email to have HTML links. You could always just put the URL into the email. Most readers will turn into a link:

Code: Select all

$bodyPT2 = $fullUrl;
You might want to look at SwiftMailer to help you easily create HTML emails. It is not that easy to create compatible MIME emails from scratch.
(#10850)
Post Reply