[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

how do I insert html (a href) into the contents of an email message

Posted on 2006-06-08
11
Medium Priority
?
308 Views
Last Modified: 2006-11-18
I have a function like this...


    require_once('Mail.php'); //---pear class
    $headers['From'] = $pFrom;
    $headers['To'] = $pTo;
    $headers['Subject'] = $pSubject;
    $params['host'] = '127.0.0.1';

    $mail_object = & Mail::factory('smtp', $params);
    $mail_object->send($pTo, $headers, $pMessage);


I want to put a url in the message eg..

<a href='www.bob.com/reportrun.php?x=1&sd=$setup->seStartingDirectory&report=$r&p=$p' target='_top'>
click here
</a>

but it displays it literally
All I want is..

click here

0
Comment
Question by:stevencopley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 30

Expert Comment

by:callrs
ID: 16867725
I think the mismatched < > pairs are causing the problem
<a .... > .... >

What if you replace the middle > with this: &#62;

----
Don't know much about email programs, but don't you have to set it to send as html and/or enclose the html part in <html>...</html> tags?
0
 

Author Comment

by:stevencopley
ID: 16867817
callrs,
I tried that but still shows all the html stuff.
0
 
LVL 30

Expert Comment

by:callrs
ID: 16867868
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 30

Expert Comment

by:callrs
ID: 16867876
0
 
LVL 2

Expert Comment

by:homemade
ID: 16873207
How about moving the part

$setup->seStartingDirectory

up on a separate line first, without knowing php something like

$tmpvar=$setup->seStartingDirectory

(if that is the syntax to set a var to something)

and then the url line something like:
<a href='www.bob.com/reportrun.php?x=1&sd=$tmpvar&report=$r&p=$p' target='_top'>


0
 
LVL 1

Expert Comment

by:beckw
ID: 16874376
Hello,

You've got a couple of issues here. First of all, if you need php to parse some variables you'll need to use " not '. Also, to make it easier to read, i'd use {} around the variables i.e.

<a href="www.bob.com/reportrun.php?x=1&sd={$setup->seStartingDirectory}&report={$r}&p={$p}" target="_top">
click here
</a>

Hope this helps
0
 
LVL 1

Expert Comment

by:beckw
ID: 16874441
Just looking at your previous code, the following syntax is probably more suited:

$pMessage = "<a href='www.bob.com/reportrun.php?x=1&sd={$setup->seStartingDirectory}&report={$r}&p={$p}' target='_top'>click here</a>";

0
 

Author Comment

by:stevencopley
ID: 16882688
Sorry everyone the html I want to put in an email is this...

<a href='www.bob.com/report.php' target='_top'>
click here
</a>

please don't get bogged down on the syntax.

Again sorry my sample was both wrong and dumb.

I want to end up with a link that just says

click here (underscored as a link to www.bob.com/report.php)

I dont want to see any html code.
in other words, I want to email a link to someone.
and I dont know how to do it.
0
 
LVL 30

Accepted Solution

by:
callrs earned 2000 total points
ID: 16884466
Step 1:
In the value of $pMessage, be sure to enclose the entire message in opening <html>  and closing </html> tags

Step 2: Set the Content-type header
$headers['MIME-Version'] = '1.0';
$headers['Content-type'] = 'text/html; charset=iso-8859-1'

Hope it works. I based the above on Example 4 at http://www.zend.com/manual/function.mail.php
0
 

Author Comment

by:stevencopley
ID: 16888940
callrs,
Thanks for sticking in there with me..
0
 
LVL 30

Expert Comment

by:callrs
ID: 16891131
Thanks for the A. And funny thing is, I've never used Pear or PHP before :O

I'm just an avid learner haha
To thank me...you gotta be nice to the environment that feeds my soul  ;)

Since you got it going, try this experiment:  Place the <html>..</html> tags only around PART of the message.
What happens to the rest of the sent message then:  Does the  non-enclosed part appear without HTML formatting, or with?
Fan example say the message is the text below. If received as text, spacing is retained. Received as HTML, 3 lines would turn into 1 line without any <BR> or <P> statements.. So what actually appears? Thanks.
-->Start of message
<html>html part of message <a href='www.bob.com/report.php' target='_top'>click here</a><html>
line one of text part
line two
line three
<--end of message
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question