Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email a hyperlink 2

Status
Not open for further replies.

likelylad

IS-IT--Management
Jul 4, 2002
388
GB
Hi

I was wondering if it was possible to email a hyperlink to someone as part of the message.

I have the following:

$Msg .= "Hi";
$Msg .= " ";
$Msg .= $_POST[entered_by];
$Msg .="\n";
$Msg .="\n";
$Msg .= "Please click on the link below to see your photo";
$Msg .="\n";
$Msg .="\n";
$Msg .= <a href=.'$_POST[find_file]'>Click Here</a>;
$Msg .="\n";
$Msg .="\n";

but it is erroring out at the "a href" part.

Thanking in advance for any help received.


Thanking in advance
 
Code:
$Msg .= "Hi";
$Msg .= " ";
$Msg .= $_POST['entered_by'];
$Msg .= "\n";
$Msg .= "\n";
$Msg .= "Please click on the link below to see your photo";
$Msg .= "\n";
$Msg .= "\n";
$Msg .= [b]'<a href="' . $_POST['find_file'] . '">Click Here</a>";[/b]
$Msg .= "\n";
$Msg .= "\n";
How about this? You had some weird concateating in the href there.
 
Oops, wrong quote at the end of the bolded (a href) line. Should be single quote.
Code:
$Msg .= "Hi";
$Msg .= " ";
$Msg .= $_POST['entered_by'];
$Msg .= "\n";
$Msg .= "\n";
$Msg .= "Please click on the link below to see your photo";
$Msg .= "\n";
$Msg .= "\n";
$Msg .= [b]'<a href="' . $_POST['find_file'] . '">Click Here</a>';[/b]
$Msg .= "\n";
$Msg .= "\n";
 
Hi Vragabond

When I recieve the email it is not hyperlinked.
The line appears as pure text.

Hi Name

Please click on the link below to check your logo

<a href="\\servername\foldername\filename.jpg">Click Here</a>


 
It depends on your e-mail client how the text is interpreted.
Your's probably requires the correct MIME heades to be provided, and it should.

Have a look at the PHPMailer class (phpmailer.sourceforge.net):
It has multi=part MIME mail, which allows you to send plain text and HTML mail as alternatives. I highly recommend to send well formed headers and messages since SPAM evaluation software takes malformed headers/messages and score them as spam.
 
Hi DRJ478 and Vragabond

Thanks for the help.
I added the following lines

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

and the code does send an email with a hyperlink.

However
When I click on the link it says that :

file://servername//foldername//filename.jpg can not be found.

Although I know the file exists at this location.

Any ideas???

 
You need to inspect what is inside $_POST['find_file']. It seems to me that the variables for the servername etc. are not interpolated when the the variable is initialized.
 
The user has to enter a pathname in a form in the following format

\\servername\foldername\filename

This address is emailed to another person

When the email is received it gives the following error

file:///servername//foldername//filename can not be found

 
The link should contain a protocol to allow the client to resolve the given address.

\\servername\foldername\filename looks like a Windows network path. Are you sure that the client receiving the mail can access that network?

The output also whows me that you need to use strip_slashes() on the variable as all forward slashes are escaped.
 
Thanks to both of you.

DRJ478: I used the stripslashes function on the variable and it now works.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top