I Need To Create A Mailto Link From Php Code
Ok, so at the moment my html form gathers data and posts it to a php form which then creates and sends an email (following code), however now I need the form to create a mailto lin
Solution 1:
As we've been discussing, you need to use NVP
in the mailto
link. For your newline breaks to be respected, you need to use urlencode()
or rawurlencode()
depending on email clients and how they respect encoding.
$to = "dave@dave.com";
$caseref = "123";
$name = "Bob";
$notes = "Some notes";
$email_subject = "Arrival some data";
$email_message = "Incident Number: " . $caseref . "\n";
$email_message .= "Arrival Date:" . date("d/m/Y");
$email_message .= "\n";
$email_message .= "Arrival Time:" . date("H:i");
$email_message .= "\n";
$email_message .= "Engineer: " . $name . " \n";
$email_message .= "Engineers Notes: " . $notes;
$email_message .= "\n";
$email_message .= "\n";
$email_message .= "\n";
// Echo the mail to linkecho'<a href="mailto:'.$to.'?subject='.urlencode($email_subject).'&body='.urlencode($email_message).'">Mail to Link</a>';
// Echo the mail to link using the different encodingecho'<a href="mailto:'.$to.'?subject='.rawurlencode($email_subject).'&body='.rawurlencode($email_message).'">Mail to Link</a>';
Also note: I've removed the time()
from your date()
function since by default time()
is used...specifying it is not necessary.
Post a Comment for "I Need To Create A Mailto Link From Php Code"