By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,441 Members | 979 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,441 IT Pros & Developers. It's quick & easy.

PHP email function

P: n/a
I have a working email functionality on my site but there's a problem
with links. I really want to use the "send this article by email" sort
of functionality on my site. But instead of emailing the entire
article I just want the email to include a link to the article and
ofcourse with query strings and all that sort of stuff the link could
be quite long. In an attempt to make the links look good and mask all
of the details I include the link in an html tag, so a very simple < a
href = " wwwwww.whatevert....com " > Click here < /a >

The problem is that it doesn't work the HTML code doesn't work in
emails. What's the solution. I even tried typing out an html coded
email using my email client and that didn't work so I guess there's
just an issue with email and html.

Anybody know a solution to sending a link via email (using PHP) and
using HTML or whatever so that the entire link isn't visible just the
CLICK here part?
Thanks

r

Jun 28 '06 #1
Share this Question
Share on Google+
9 Replies


P: n/a
ro**********@gmail.com:
I have a working email functionality on my site but there's a problem
with links. I really want to use the "send this article by email" sort
of functionality on my site. But instead of emailing the entire
article I just want the email to include a link to the article and
ofcourse with query strings and all that sort of stuff the link could
be quite long. In an attempt to make the links look good and mask all
of the details I include the link in an html tag, so a very simple < a
href = " wwwwww.whatevert....com " > Click here < /a >

The problem is that it doesn't work the HTML code doesn't work in
emails. What's the solution. I even tried typing out an html coded
email using my email client and that didn't work so I guess there's
just an issue with email and html.


I would agree that there is an issue with HTML in e-mails. There is
a body of opinion that says that e-mail and HTML don't click. They
don't get on. Assuming you have considered this...

Couple of questions. Is the Content-Type of the body part set to
text/html? That is, have you told the mail client what format the
message is in? Does the user-agent support, and is it configured to
interpret HTML mail?

One of the design principles of URLs is that they have fewer than ~70
characters, so that they fit on a single line in, for example, e-mails.
Are you perhaps addressing the symptom rather than the cause?

--
Jock

Jun 28 '06 #2

P: n/a
^you are on to something.

I think the content-type is the culprit, but i'm at a lose as to how to
incorporate the content-type into the mail function.

here's my code
mail($EmailTo, $Subject, $Body, "From: '$SName' <$EmailFrom>");

where would conent type go? as one of the headers or within the body?

Jun 28 '06 #3

P: n/a
<comp.lang.php>
<>
<28 Jun 2006 07:36:58 -0700>
<11**********************@b68g2000cwa.googlegroups .com>
I have a working email functionality on my site but there's a problem
with links. I really want to use the "send this article by email" sort
of functionality on my site. But instead of emailing the entire
article I just want the email to include a link to the article and
ofcourse with query strings and all that sort of stuff the link could
be quite long. In an attempt to make the links look good and mask all
of the details I include the link in an html tag, so a very simple < a
href = " wwwwww.whatevert....com " > Click here < /a >


Have you asked people if they want a html (Click here) link instead of a
plain text link ? .
--
www.emailuser.co.uk/?name=KRUSTOV
Jun 28 '06 #4

P: n/a
^
they definitely want a clickable link instead of the full url path.
but in the end if I can't get this clickable link to work i'll just
have to do it as text. Although that even rises a problem. When the
email displays the a href html tag it reads part of the url and makes
it a hyper link.... but the url has spaces in it....(I know not my
doing but there are spaces) there fore it makes the conjoined part of
the url a link and leaves everything after the space regular text and
that looks worse than if it were all just regular text.

Jun 28 '06 #5

P: n/a

ro*****@gmail.com wrote:
^
they definitely want a clickable link instead of the full url path.
but in the end if I can't get this clickable link to work i'll just
have to do it as text. Although that even rises a problem. When the
email displays the a href html tag it reads part of the url and makes
it a hyper link.... but the url has spaces in it....(I know not my
doing but there are spaces) there fore it makes the conjoined part of
the url a link and leaves everything after the space regular text and
that looks worse than if it were all just regular text.


Try using the php mail class, it has options for specifing html and an
alternate for non html recipients (can't remeber how this works
multipart/alternative header to the message I think??) it also has a
load of other useful bits and pieces in it which makes it a little more
secure and basically more useful than using php's mail() alone

You can find it here: http://phpmailer.sourceforge.net/

Deano

Jun 28 '06 #6

P: n/a
Deano:
Try using the php mail class, it has options for specifing html and an
alternate for non html recipients


Not convinced this is useful, in general. I think it would be better
to find out what format the person prefers to receive e-mails in and
send their e-mails in that format only. For example, you could default
to text/plain and have an opt-in option for text/html.

--
Jock

Jun 29 '06 #7

P: n/a
ro**********@gmail.com:
I think the content-type is the culprit, but i'm at a lose as to how to
incorporate the content-type into the mail function.


As an additional header.

http://www.php.net/manual/en/function.mail.php

--
Jock

Jun 29 '06 #8

P: n/a
^thnx, i'll try this out

the php mail class seems a bit too complicated and long for the simple
function I want

gratzi

Jun 29 '06 #9

P: n/a
it worked thanks Jock

woohoo

Jun 29 '06 #10

This discussion thread is closed

Replies have been disabled for this discussion.