Forum Moderators: coopster

Message Too Old, No Replies

Link that opens default Email program via header?

Is this possible?

         

Hester

10:49 am on Jun 23, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I want to make a link on a page that opens a second page which then opens the user's email program. Normally this would happen if you code the link using "mailto" in HTML, but that attracts spam. At present the email address is produced via JavaScript using an anti-spam technique. I have made another page which redirects the user to a different page via a standard header in PHP. But is it possible to make the header go not to a webpage but act like a "mailto" link? I tried the following code but it did not work:

<?php
$query = $_SERVER['QUERY_STRING'];
if ($query == '') {exit('ERROR: No query string found at end of web address!');}
if ($query == 'chris') {$address = '-my-email-address-here-';}
$link = 'mailto:'.$address;
header($link); //I also tried location:$link
?>

The HTML would then look like this:

<a href="email.php?chris">email me!</a>

I can't find anything in the online PHP Manual about this. Is it possible at all?

scriptmasterdel

12:02 pm on Jun 23, 2006 (gmt 0)

10+ Year Member




<?php
if(empty($_SERVER['QUERY_STRING']))
{
exit('ERROR: No query string found at end of web address!');
}
elseif($_SERVER['QUERY_STRING']=='derek')
{
$address = 'you@my-email-address.co.uk';
}

if(!empty($address))
{
header("Location: mailto:".$address);
}
?>

I think the header location is needed to process the mailto request!

This code has been tester (that makes a difference for me) and it's a cool idea to reduce spambots grabbing e-mail addresses guess

Good luck

Del

Hester

1:16 pm on Jun 23, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for that. Whatever I try, I notice the page just hangs. It looks like it's waiting for something more to download. What's up?