Jump to content

Recommended Posts

Hi,

 

I've got a PHP Contact Form working no worries, But what I'd like it to do is make it so that the $email address that was posted by the form is a link to create a new mail as in the HTML Code "mailto:blabla@blabla.com"

 

At the moment the form is producing this....

Contact Details for Test are :

 

E-Mail Address : test@test.co.uk

 

Contact Phone Number : test

 

Address : Test

 

Message : Test Message

 

How do I make that "mailto:test@test.co.uk" ?? The E-Mail client (If needed) is MS Outlook 2003

 

I also see that this site has picked it up as an E-Mail address, But outlook isnt  >:(

 

Current PHP Code is :

<?php
ini_set("sendmail_from", " bookings@alnwicklodge.com");
//$to = "bookings@alnwicklodge.com";
$to = "stuartblackett@fantasyprints.co.uk";
$subject = "Alnwick Lodge Contact";
$name = $_POST["name"];
$email = $_POST["email"];
$phone = $_POST['phone'];
$fax = $_POST['fax'];
$address = $_POST['address'];
$address2 = $_POST['address2'];
$postcode = $_POST['postcode'];
$message = $_POST['message'];

$messagesent = "Alnwick Lodge Website Query
--------------------------------------------------------------------------------------------------------------------------------------------------------------
Contact Details for $name are : 

E-Mail Address : $email

Contact Phone Number : $phone 

Address : $address $address2 $postcode

Message : $message 
--------------------------------------------------------------------------------------------------------------------------------------------------------------
";

$from = $_POST["email"];
$headers = "Message From: $from";
mail($to,$subject,$messagesent,$headers);
echo "Your message has been sent to us, we will be in contact shortly. thank you.";
?>

Link to comment
https://forums.phpfreaks.com/topic/112550-mail-form-making-it-mailto-user/
Share on other sites

just make a link like so

 

<a href="mailto:<?php echo $email; ?>"><?php echo $email ?></a>

 

The forms just erroring out and as my hosting have switched off PHP Errors I cant see the reason why  ::)

 

I thought that would have been the answer aswell...

 

Code (That is erroring) is now :

<?php
ini_set("sendmail_from", " bookings@alnwicklodge.com");
//$to = "bookings@alnwicklodge.com";
$to = "stuartblackett@fantasyprints.co.uk";
$subject = "Alnwick Lodge Contact";
$name = $_POST["name"];
$email = $_POST["email"];
$phone = $_POST['phone'];
$fax = $_POST['fax'];
$address = $_POST['address'];
$address2 = $_POST['address2'];
$postcode = $_POST['postcode'];
$message = $_POST['message'];

$messagesent = "Alnwick Lodge Website Query
--------------------------------------------------------------------------------------------------------------------------------------------------------------
Contact Details for $name are : 

E-Mail Address : <a href="mailto:<?php echo $email; ?>"><?php echo $email ?></a>

Contact Phone Number : $phone 

Address : $address $address2 $postcode

Message : $message 
--------------------------------------------------------------------------------------------------------------------------------------------------------------
";

$from = $_POST["email"];
$headers = "Message From: $from";
mail($to,$subject,$messagesent,$headers);
echo "Your message has been sent to us, we will be in contact shortly. thank you.";
?>

Still no joy  >:(

 

Do you think its something to do with the way my information is layed out?

 

<?php
ini_set("sendmail_from", " bookings@alnwicklodge.com");
//$to = "bookings@alnwicklodge.com";
$to = "stuartblackett@fantasyprints.co.uk";
$subject = "Alnwick Lodge Contact";
$name = $_POST["name"];
$email = $_POST["email"];
$phone = $_POST['phone'];
$fax = $_POST['fax'];
$address = $_POST['address'];
$address2 = $_POST['address2'];
$postcode = $_POST['postcode'];
$message = $_POST['message'];

$messagesent = "Alnwick Lodge Website Query
--------------------------------------------------------------------------------------------------------------------------------------------------------------
Contact Details for $name are : 

E-Mail Address :<?php echo '<a href="mailto:$email">$email</a>';

Contact Phone Number : $phone 

Address : $address $address2 $postcode

Message : $message 
--------------------------------------------------------------------------------------------------------------------------------------------------------------
";

$from = $_POST["email"];
$headers = "Message From: $from";
mail($to,$subject,$messagesent,$headers);
echo "Your message has been sent to us, we will be in contact shortly. thank you.";
?>

 

I've put in what was suggested, I also put it in with the close ?> PHP Tag, But that also didnt work, So I've left it to show what I've got so far

 

Is it worth trying to set $email as a seperate variable?

 

As in :

$respondto = <a href="mailto:$email">

 

or something of that sorts?

try this:

<?php
  ini_set("sendmail_from", " bookings@alnwicklodge.com");
  //$to = "bookings@alnwicklodge.com";
  $to = "stuartblackett@fantasyprints.co.uk";
  $subject = "Alnwick Lodge Contact";
  $name = $_POST["name"];
  $email = $_POST["email"];
  $phone = $_POST['phone'];
  $fax = $_POST['fax'];
  $address = $_POST['address'];
  $address2 = $_POST['address2'];
  $postcode = $_POST['postcode'];
  $message = $_POST['message'];
  
  $messagesent = "Alnwick Lodge Website Query
--------------------------------------------------------------------------------------------------------------------------------------------------------------
Contact Details for $name are : 

E-Mail Address : <a href='mailto : $email'>$email</a>

Contact Phone Number : $phone 

Address : $address $address2 $postcode

Message : $message 
--------------------------------------------------------------------------------------------------------------------------------------------------------------
";
  
  $from = $_POST["email"];
  $headers = "Message From: $from";
  mail($to, $subject, $messagesent, $headers);
  echo "Your message has been sent to us, we will be in contact shortly. thank you.";
?>

Hmmm, The form went through

 

But the E-Mail result was this :

 

Contact Details for Test are :

 

E-Mail Address : <a href="mailto:$email">$email</a>

 

Contact Phone Number : 01289334495

 

Address : Berwick Upon Tweed test TD15 1TB

 

Message : Test Message

try this:

<?php
  ini_set("sendmail_from", " bookings@alnwicklodge.com");
  //$to = "bookings@alnwicklodge.com";
  $to = "stuartblackett@fantasyprints.co.uk";
  $subject = "Alnwick Lodge Contact";
  $name = $_POST["name"];
  $email = $_POST["email"];
  $phone = $_POST['phone'];
  $fax = $_POST['fax'];
  $address = $_POST['address'];
  $address2 = $_POST['address2'];
  $postcode = $_POST['postcode'];
  $message = $_POST['message'];
  
$messagesent = "Alnwick Lodge Website Query";
$messagesent .= "-----------------------------------------------------------";
$messagesent .= "------------------------------------------------------------";
$messagesent .= "---------------------------------------<br>";
$messagesent .= "Contact Details for " . $name . " are :<br>"; 
$messagesent .= "E-Mail Address : <a href='mailto :" . $email . "'>" . $email . "</a><br>";
$messagesent .= "Contact Phone Number : " . $phone . "<br>";
$messagesent .= "Address : " . $address . $address2 . $postcode . "<br>";
$messagesent .= "Message : " . $message . "<br>";
$messagesent .= "--------------------------------------------------------";
$messagesent .= "---------------------------------------------------------";
$messagesent .= "-------------------------------------------";
  
  $from = $_POST["email"];
  $headers = "Message From: $from";
  mail($to, $subject, $messagesent, $headers);
  echo "Your message has been sent to us, we will be in contact shortly. thank you.";
?>

 

see if that works.

Still no joy, I'm afraid  >:(

 

Its pulling through the HTML Tags in the E-Mail

 

This is what the response was :

 

Alnwick Lodge Website Query--------------------------------------------------------------------------------------------------------------------------------------------------------------<br>Contact Details for Test are :<br>E-Mail Address : <a href='mailto :stuartblackett@fantasyprints.co.uk'>stuartblackett@fantasyprints.co.uk</a><br>Contact Phone Number : test<br>Address : Berwick Upon TweedHartlepoolTD15 1TB<br>Message : Test Message<br>------------------------------------------------------------------------------------------------------------------------------------------------------------

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.