Jump to content

Mail Form, Making it mailto: USER


stublackett

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:[email protected]"

 

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

Contact Details for Test are :

 

E-Mail Address : [email protected]

 

Contact Phone Number : test

 

Address : Test

 

Message : Test Message

 

How do I make that "mailto:[email protected]" ?? 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", " [email protected]");
//$to = "[email protected]";
$to = "[email protected]";
$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", " [email protected]");
//$to = "[email protected]";
$to = "[email protected]";
$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", " [email protected]");
//$to = "[email protected]";
$to = "[email protected]";
$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", " [email protected]");
  //$to = "[email protected]";
  $to = "[email protected]";
  $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", " [email protected]");
  //$to = "[email protected]";
  $to = "[email protected]";
  $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 :[email protected]'>[email protected]</a><br>Contact Phone Number : test<br>Address : Berwick Upon TweedHartlepoolTD15 1TB<br>Message : Test Message<br>------------------------------------------------------------------------------------------------------------------------------------------------------------

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.